tags:

views:

22

answers:

1
<div id="compv-navbar">
        <a href="#"><img src="image1.png" id="icon1"></a> | 
        <a href="#"><img src="image2.png" id="icon2"></a> | 
        <a href="#"><img src="image3.png" id="icon3"></a> | 
        <span id="view_name"> 2-up</span>
    </div>

Assume the names of the new images follow this formula:

name + "-hover". So image1.png = image1-hover.png"

Edit: I don't understand why the downvote happened?

+1  A: 

You can do it using .hover() and just do a .replace() on the src attribute, like this:

$("#compv-navbar a img").hover(function() {
  this.src = this.src.replace('.png', '-hover.png');
}, function() {
  this.src = this.src.replace('-hover.png', '.png');
});
Nick Craver