我想要多个 div id 来启动这个动画。为什么这不起作用?
我的意思是:
$("#treest, #treest2, #treest3").click(function() {
anim10();
});
这是完整的代码
/** ANIMATE DropDown */
var $a = $("#navigation"),
$b = $(".mainNavitem:eq(1)"),
$c = $(".c");
function anim1() {
$b.animate({width: 395}, {duration: 300, complete: anim2});
}
function anim2() {
$a.animate({top:"70px"}, {duration: 400});
$c.animate({top:"70px"}, {duration: 400});
}
$("#mains").click(function() {
anim1();
});
function anim10() {
$c.animate({top:"0px"}, {duration: 200});
$a.animate({top:"0px"}, {duration: 200 , complete: anim20});
}
function anim20() {
$b.animate({width: 80}, {duration: 200});
}
$("#treest, #treest2, #treest3").click(function() {
anim10();
});
你知道我该如何解决这个问题吗?
编辑:
最佳答案
您是否使用 $(document).ready() 事件运行代码?喜欢
jQuery(function(){
$("#mains").click(function() {
anim1();
});
$("#treest, #treest2, #treest3").click(function() {
anim10();
});
})
关于javascript - 激活多个 id jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21110384/