放大几张图像

时间:2015-10-25 19:31:35

标签: jquery image zoom

我需要在悬停时缩放不同DIV内的图像;我可以一次缩放所有图像,但不是唯一的。

archives



img2

$('img').load(function() {
    $(this).data('height', this.height);
}).bind('mouseenter mouseleave', function(e) {
    $(this).stop().animate({
        height: $(this).data('height') * (e.type === 'mouseenter' ? 1.5 : 1)
    });
});

body {
    background:black;
}
img {
    display:block; 
    margin:10px; 
    height: 20%;
}
div {
    background:red;
    height: 200px;
    width: 200px;   
}




1 个答案:

答案 0 :(得分:0)

试试这个: -

PlaySound

Fiddle

您将$('img').load(function() { $(this).data('height', this.height); }) $('.imagen').on('mouseenter mouseleave', function(e) { var img = $(this).children('img'); $(img).stop().animate({ height: $(img).data('height') * (e.type === 'mouseenter' ? 1.5 : 1) }); }); mouseenter绑定到mouseleave而非父img