/ Published in: jQuery
                    
                                        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();
                Example: $("img.rollover").rollover();
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 (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);
Comments
                    Subscribe to comments
                
                