Revision: 24998
Updated Code
at March 20, 2010 08:54 by frankyfish
Updated Code
(function($){ $.fn.extend({ rollover: function() { return this.each(function(i, el) { if(el.nodeName == "SPAN") { if($(el).data("fileName") == undefined) { var tmp = el.css("filter").split("'")[1]; $(el).data("extension", tmp.pop()); $(el).data("fileName", tmp.join(".")); } $(el).hover( function() { $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src=\'"+$(el).data("fileName")+"_hover."+$(el).data("extension")+"\', sizingMethod='scale')") }, function() { $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src=\'"+$(el).data("fileName")+"."+$(el).data("extension")+"\', sizingMethod='scale')") } ); } else { if($(el).data("fileName") == undefined) { var tmp = el.src.split("."); $(el).data("extension", tmp.pop()); $(el).data("fileName", tmp.join(".")); } $(el).hover( function() { $(this).attr("src", $(this).data("fileName")+"_hover."+$(this).data("extension")) }, function() { $(this).attr("src", $(this).data("fileName")+"."+$(this).data("extension")) } ); } }); } }); })(jQuery);
Revision: 24997
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 17, 2010 14:09 by frankyfish
Initial Code
(function($){ $.fn.extend({ rollover: function() { return this.each(function(i, el) { if(el.nodeName == "IMG") { if($(el).data("fileName") == undefined) { var tmp = el.src.split("."); $(el).data("extension", tmp.pop()); $(el).data("fileName", tmp.join(".")); } $(el).hover( function() { $(this).attr("src", $(this).data("fileName")+"_hover."+$(this).data("extension")) }, function() { $(this).attr("src", $(this).data("fileName")+"."+$(this).data("extension")) } ); } else if(el.nodeName == "SPAN") { if($(el).data("fileName") == undefined) { var tmp = el.css("filter").split("'")[1]; $(el).data("extension", tmp.pop()); $(el).data("fileName", tmp.join(".")); } $(el).hover( function() { $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src=\'"+$(el).data("fileName")+"_hover."+$(el).data("extension")+"\', sizingMethod='scale')") }, function() { $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src=\'"+$(el).data("fileName")+"."+$(el).data("extension")+"\', sizingMethod='scale')") } ); } }); } }); })(jQuery);
Initial URL
Initial Description
What it does is look for img tag and on rollover change the source path from "anyimage.jpg" to "anyimage_hover.jpg". It add the suffix "_hover" at the end of the src name without changing the extension. If you look at the code you will see that it also take the span tag. This is to support ie6 png image that has been transform by a pngfix. Example: $("img.rollover").rollover();
Initial Title
jQuery RollOver plugin
Initial Tags
javascript, plugin, jquery
Initial Language
jQuery