jamo

jQuery domroll

Jun 7th, 2011
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.53 KB | None | 0 0
  1. /* jQuery domroll
  2.    Modifies all image elements with a "domroll" class. Appends "_f2" to the source filename to create a roll-over image.
  3.    Idea based on http://www.dynamicdrive.com/dynamicindex15/domroll.htm
  4.    Requires jQuery and jQuery.Preload http://flesler.blogspot.com/2008/01/jquerypreload.html
  5. */
  6.  
  7. $(function(){
  8.     $.preload('.domroll', {find:/\.([^\.]+)$/, replace:'_f2.$1'});
  9.     $('.domroll').hover(function(){this.src = this.src.replace(/\.([^\.]+)$/,'_f2.$1');},function(){this.src = this.src.replace('_f2','');});
  10. });
Advertisement
Add Comment
Please, Sign In to add comment