我想.toggle .animation。你能帮我弄清楚为什么这个 jquery 代码不起作用吗?
$(document).ready(function() {
$('.adiv').toggle(
function(){
$(this).animate({
width: "150",
height: "150",
}, 1000);
},
function(){
$(this).animate({
width: "77",
height: "77",
}, 1000);
});
});
感谢您的帮助!
最佳答案
注意:您的代码运行良好!问题很简单:在你的 jsfiddle 中,你忘记导入 jquery!使用左侧的侧边栏再试一次!
顺便说一句,这是我使用 mouseover 和 mouseout 的解决方案:
$(document).ready(function() {
$('.adiv').mouseover(function()
{$(this).animate({
width: "150",
height: "150"
}, 1000);
}).mouseout(
function(){
$(this).animate({
width: "77",
height: "77"
}, 1000);
});
});
关于javascript - Jquery .toggle .animate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24737789/