<script type="text/javascript">
$(function(){
$(".user_ava").click(function() {
$("div:.userMenu",this ).animate({
height: ["toggle", "swing"],
opacity: "toggle"
}, 200, "linear");
});
});
</script>
错误:消息(未捕获错误:语法错误,无法识别的表达式::。userMenu)
答案 0 :(得分: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>
答案 1 :(得分:2)
删除“div:.userMenu”中的“:”
<script type="text/javascript">
$(function(){
$(".user_ava").click(function() {
$("div.userMenu",this ).animate({
height: ["toggle", "swing"],
opacity: "toggle"
}, 200, "linear");
});
});
</script>
答案 2 :(得分:2)
将div:.userMenu
更改为div.userMenu