Reputation: 1126
I am trying to use this jQuery function to make my image zoom as well as have a sliding text appear on hover. I want to use a total of 13 images that each have different dimensions. When I put more than one class in the jQuery function all the classes inherit the first class's css properties even though each image has it's own unique css properties. How do I design my function so that each class does not inherit the first class's css code?
<script>
$(document).ready(function() {
//move the image in pixel
var move = -15;
//zoom percentage, 1.2 =120%
var zoom = 1.2;
//On mouse over those thumbnail
$('.zitem, .take2').hover(function() {
//Set the width and height according to the zoom percentage
width = $('.zitem, .take2').width() * zoom;
height = $('.zitem, .take2').height() * zoom;
//Move and zoom the image
$(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:1000});
//Display the caption
$(this).find('div.caption').stop(false,true).fadeIn(200);
},
function() {
//Reset the image
$(this).find('img').stop(false,true).animate({'width':$('.zitem, .take2').width(), 'height':$('.zitem, .take2').height(), 'top':'0', 'left':'0'}, {duration:500});
//Hide the caption
$(this).find('div.caption').stop(false,true).fadeOut(200);
});
});
</script>
Upvotes: 1
Views: 101