mootools php faith camera linux


HTMLDog's sfhover

Note: this is based on the mootools versions v1.11.

HTMLDog wrote a great sfhover.js to deal with the pseudo class problems in ie6. As of the writing of this article, ie6 still has about 30% of the browser share (it is sad that ie7 had to be so much different that people won't switch...they could have just fixed what was wrong rather than COPY firefox :( .) Anyway, I digress; here is the sfhover.js by HTMLDog:

// JavaScript Document
//sfHover couresty of (
sfHover = function() {
sfEls document.getElementById("menu").getElementsByTagName("li");
    for (var 
i=0i<sfEls.lengthi++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhoverb"), "");
if (

Mootools can make this better most quickly, by using the mootool dollars $$('css selector here') to get an array of elements in much less code. Then using the addClass and removeClass element function and the array iterator, we can knock this out really quickly:

.addEvent('load',function() {
'#menu li').each(function(item) {
item.addEvent('mouseover',function() { item.addClass('sfhover'); });
item.addEvent('mouseout',function() { item.removeClass('sfhover'); });

Thanks to HTMLDog and MooTools for showing us the way!

Last Updated: 2008-09-18 07:49:49
Creative Commons License Jay Johnston is a Zend Certified Engineer in PHP 5 LPI-ID: LPI000102450, Verfication Code: wmnnt56y2k  ... Jay Johnston is certified as LPIC-1 by the Linux Professional Institute