I didn't test that exact code, but here's something similar I'm using in an app to apply an IE6 hover fix on dynamically created elements. This is the code that prompted this question.
Code:
var oClasses = ["mm3_LargeResult", "mm3_TileResult", "mm3_SmallResult", "mm3_TextOnlyRow"];
for(var i=0; i<oClasses.length; i++){
(function(){
var oElements = YAHOO.util.Dom.getElementsByClassName(oClasses[i]);
var oHoverClass = oClasses[i] + "_hover";
for(var j=0; j<oElements.length; j++){
oElements[j].onmouseover = function(){
YAHOO.util.Dom.addClass(this, oHoverClass);
}
oElements[j].onmouseout = function(){
YAHOO.util.Dom.removeClass(this, oHoverClass);
}
}
})();
}
This code is working fine for me but only runs in IE6 (I'm using browser detection for that... is there a feature detection method for determining :hover/:active limitations?). If I take out the self-executing function, it doesn't work, and following my first example for any "var" declarations doesn't work in this case either.
Bookmarks