我试图在鼠标悬停时放大图像,并在mouseout后缩小尺寸.我有以下内容:
$('#image img').live("mouseover", function(){
var $this=$(this);
$this.attr('width','25%');
$this.attr('height','25%');
})
Run Code Online (Sandbox Code Playgroud)
放大部分工作正常,但我不知道如何减小鼠标后的大小.此外,我认为我的代码有点难看,不知道如何解决它.非常感谢.
Tat*_*nit 14
试试这个:http ://jsfiddle.net/FPKAP/11/ 或使用悬停:http://jsfiddle.net/FPKAP/12/
当您将鼠标悬停在HULK上时,它将缩放并在鼠标移出时缩小.
这应该有助于需要,知道我是否误解了任何事情, :)
码
$('#zoomimg').mouseenter(function() {
$(this).css("cursor","pointer");
$(this).animate({width: "50%", height: "50%"}, 'slow');
});
$('#zoomimg').mouseleave(function() {
$(this).animate({width: "28%"}, 'slow');
});
Run Code Online (Sandbox Code Playgroud)
码
$('#zoomimg').hover(function() {
$(this).css("cursor", "pointer");
$(this).animate({
width: "50%",
height: "50%"
}, 'slow');
}, function() {
$(this).animate({
width: "28%"
}, 'slow');
});?
Run Code Online (Sandbox Code Playgroud)