jQuery.fn.makeHot = function(settings) {
var settings = jQuery.extend({
sub: "_hot",
}, settings);
jQuery(this).each( function ()
{
var src = jQuery(this).attr("src");
var ext = src.substring(src.lastIndexOf('.'), src.length);
src = src.substring(0, src.lastIndexOf('.'));
jQuery(this).hover(
function(){
jQuery(this).attr("src", src + settings['sub']
+ ext);
},
function(){
jQuery(this).attr("src", src + ext);
}
);
});
};
I believe that it is pretty selfexplanatory. the only setting atm is
"sub" which defaults to "_hot" so lets say you call the function for a
image with src="img/delete.gif", when hovered it changes the src to
"img/delete_hot.gif", that is unless you change the defaults. Have
worked nicely for my needs so I thought someone out there might want
this.
btw before I did have a option of searching for img, so that if you
would call it with $("div .menu") it would use a find("img") to get
them, but I removed it cause I never actually used it.
any input on this little snippet is as always welcome!
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/