I have 6 images in a line, the first one when the page loads has a class applied to it which using CSS3 applies web transformations. When the other images are hovered over the same class is applied to these, then removed when mouseout. The final thing I need to achieve is that when the other images are hovered over the first one has the class removed, and if no images are hovered over the first one has its class applied to it again.
Here is what I have so far:
$(document).ready(function() {
$("#imagePackshot li img").hover(function(){
$(this).addClass('packshot').siblings().removeClass('packshot');
},
function () {
$(this).removeClass('packshot');
})
.first().addClass('packshot');
});
You’ll want to check after you remove a class whether there are no other images with the class ‘packshot’, in that case add it to the first one.
Edit:
The code is using this html structure, based on the link you posted, which means you can’t use “siblings” to refer to the next images, since the images aren’t siblings in the html tree: