Jump to content

Change picture on hover


theme

Recommended Posts

  • 2 months later...

There are two ways to achieve this resoult (maybe more but I don't know them):
1) CSS version
add to template 2nd image (this one which you want to appear on hover) and hide him (display: none), after this use .hovered class or :hover pseudo-class to display: block propper image and hide first one.

2) jQuery version
use
http://api.jquery.com/hover/
http://api.jquery.com/attr/
something like this:
$('[css li selector]').hover(function(){
   $('[css image selector]').attr('src', '[link to new image]');

},{

   $('[css image selector]').attr('src', '[link to old image]');

});

 

best way to get only hovered image selector will be
  $(this).find('img [you can add classes like in css here]')....

 

I've only described the ways to achieve this, it's not a tutorial

Edited by falkor (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...