Posted By

noah on 06/11/07


Tagged

ie DOM hover dhtml robzand utilities broken css2 workaround


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

luman
vali29


Set IE Hover State


 / Published in: JavaScript
 

assigns/removes the class 'over' to elements on hover since IE does not attach :hover to any element but A

  1. setIEHoverState : function (id,tagname) { //fix the :hover pseudoclass in IE6-
  2. el = document.getElementById(id);
  3. if(el) {
  4. tn = el.getElementsByTagName(tagname);
  5. for(i=0;i<tn.length;i++){
  6. tn[i].onmouseover= function(){
  7. this.className ? this.className += ' over' : this.className = 'over';
  8. }
  9. tn[i].onmouseout = function(){
  10. this.className = this.className.match(/ over/) ? this.className.replace(/ over/,'') : this.className.replace(/^over/,'');
  11. }
  12. }
  13. }
  14. }

Report this snippet  

You need to login to post a comment.