tags:

views:

102

answers:

1

Hi,

I am attempting to do a simple image swap on mouseover event with YUI. Is this a simple task? As when I google all I get is plugins.

Thanks.

+2  A: 

Simple, but gives you an idea of how YUI events work.

YAHOO.util.Event.on("element_id", "mouseover", function(e) {
    var tgt = YAHOO.util.Event.getTarget(e);

    YAHOO.util.Dom.addClass(tgt, "hover");
}

YAHOO.util.Event.on("element_id", "mouseout", function(e) {
    var tgt = YAHOO.util.Event.getTarget(e);

    YAHOO.util.Dom.removeClass(tgt, "hover");
}
Tivac