Hi all,
I don't know if this is implemented in someway in jQuery or someone else
wrote something similar but I ended up needing two short plugins for adding
and removing Classnames:
It exists toggleClass which shortens the way for adding/removing a classname
for click events.
Here it is a "hoverClass" for mouseover and mouseout events:
$.fn.hoverClass = function(c) {
return this.each(
function(){
var e = $(this);
e.hover(function(){e.addClass(c)},
function(){e.removeClass(c)});
});
}
And "pressClass" for mousedown and mouseup events:
$.fn.pressClass = function(c) {
return this.each(
function(){
var e = $(this);
e.mousedown(function(){e.addClass(c)}).mouseup(function(){e.removeClass(c)})
;
});
}
,this way, you can add different flavours to elements depending in your
interaction (like "buttons" look&feel).
Demos:
$('.buttonBehaviour')
.hoverClass('hover')
.pressClass('press')
,please, if you find them usefull, tell me if there is a more efficient way
of coding them ;-)
Thanxs,
Enrique Meléndez Estrada
Servicios Informáticos
Organización y Servicios Internos
Instituto Tecnológico de Aragón
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/