-1
<script type="text/javascript">
$(function(){
    $(".user_ava").click(function() {
        $("div:.userMenu",this ).animate({
            height: ["toggle", "swing"],
            opacity: "toggle"
        }, 200, "linear");
    });
});
</script>

错误:消息(未捕获的错误:语法错误,无法识别的表达式::.userMenu)

4

3 回答 3

4

中的冒号"div:.userMenu"不正确,jquery 无法识别。如果你想<div>userMenu类全选,语法是

$("div.userMenu",this );

完整脚本:

<script type="text/javascript">
$(function(){
    $(".user_ava").click(function() {
        $("div.userMenu",this ).animate({ // you had a colon here for some reason
            height: ["toggle", "swing"],
            opacity: "toggle"
        }, 200, "linear");
    });
});
</script>
于 2012-08-10T17:18:46.597 回答
2

删除“div:.userMenu”中的“:”

<script type="text/javascript">
$(function(){
    $(".user_ava").click(function() {
        $("div.userMenu",this ).animate({
            height: ["toggle", "swing"],
            opacity: "toggle"
        }, 200, "linear");
    });
});
</script>
于 2012-08-10T17:19:47.813 回答
2

更改div:.userMenudiv.userMenu

于 2012-08-10T17:20:20.270 回答