繁体   English   中英

激活多个id jQuery

[英]Activate more than one id jQuery

我想有多个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();
    });
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM