I am working on making a product page for metal address numbers for a website, the number comes in 4 different colors, I want to make it so people can hover over a div that is a certain color, gold, chrome, black or brown, and the image of the number will change accordingly.
Here is an example of it done on a different website: http://www.mailboxes.com/departments/custom-signage/numbers-and-letters/brass-number-6/
I'm not asking how to filter the image to make it change colors, I have the different images for different colors already, I just want to know what the best way to swap out those images are, I know about :hover in CSS, but with 4 different images to switch to that wouldn't work. So I'm assuming jQuery will be required here.
Here's what I've tried:
My HTML:
<div class="address-numbers">
<div class="numberzero"></div>
<h3 class="address-title">4" Brass Number 0</h3>
<h4 class="product-number">Model# 25-BN4-0</h4>
<h4 class="address-price"><strong>$4.99</strong></h4>
<div class="colors">
<div class="antique"></div>
<div class="brass"></div>
<div class="chrome"></div>
<div class="black"></div>
</div>
</div>
My relevant CSS:
.chrome {
width: 35px;
height: 20px;
float: left;
background-color: #DBDBDB;
border: 1px solid black;
margin-left: 5px;
}
.zero-chrome {
background-image: url(address_numbers/number5_old.jpg);
}
.numberzero {
width: 85px;
height: 125px;
background-image: url(address_numbers/taymor0.jpg);
}
And my jQuery:
$(document).ready(function() {
$('.chrome').hover(function() {
$('.numberzero').toggleClass('zero-chrome');
});
});
What should happen is that when hovering over the .chrome div, the image that is currently set by .numberzero should change when the class .zero-chrome is added to the div via jQuery.