Advertisement
arkader

Image mouseenter / mouseleave (no fade)

Oct 31st, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.60 KB | None | 0 0
  1. var home =  {
  2.  
  3.         init:function() {
  4.  
  5.             $('div#bloc2')
  6.                 .children('div')
  7.                 .find('img')
  8.                 .on('mouseenter',this.mouseenter)
  9.                 .on('mouseleave',this.mouseleave);
  10.  
  11.         },//init
  12.  
  13.         mouseenter: function() {
  14.  
  15.             var alt = $(this).attr('alt'); //alt contains the name without .png
  16.  
  17.             $(this).attr('src',function(){
  18.                 return 'assets/img/home/'+alt+'_mouseover.png';
  19.             });
  20.  
  21.         },//mouseenter
  22.  
  23.         mouseleave:function(){
  24.  
  25.             var alt = $(this).attr('alt');
  26.  
  27.             $(this).attr('src',function(){
  28.                 return 'assets/img/home/'+alt+'.png';
  29.             });
  30.  
  31.         }//mouseleave
  32.  
  33.     };//home
  34.  
  35.     home.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement