Javascript 在jQuery中使用错误的语法 $screenWidth=$(document).width(); 如果($screenWidth
显然,我在这里使用的语法不正确。错在哪里Javascript 在jQuery中使用错误的语法 $screenWidth=$(document).width(); 如果($screenWidth,javascript,jquery,html,if-statement,syntax,Javascript,Jquery,Html,If Statement,Syntax,显然,我在这里使用的语法不正确。错在哪里 document.getElementById,您有一个额外的s 另外,由于您使用的是jquery,因此可以执行以下操作: $screenWidth = $(document).width(); if ($screenWidth < 980) { document.getElementsById("show-menu").removeAttribute("checked"); alert($screenW
document.getElementById
,您有一个额外的s
另外,由于您使用的是jquery,因此可以执行以下操作:
$screenWidth = $(document).width();
if ($screenWidth < 980) {
document.getElementsById("show-menu").removeAttribute("checked");
alert($screenWidth);
}
getElementById,而不是元素。ID应该是唯一的,因此获取倍数无论如何都没有意义。它不会删除选中的属性。您应该在javascript控制台中看到“nota function”,它会指向这一行。您是否尝试查看代码?发帖前你试过什么吗?是的,我当然试过了
$('#show-menu').removeAttr('checked');