点击 id="check_user"警报不起作用。这是我的代码。
<html>
<script>
$("#check_user").click(function(){
alert("good");
});
</script>
<body>
<label name="email">Email</label>
<input type="email" id="log_user_email" placeholder="example@example.com" />
<label name="password">Password</label>
<input type="password" id="log_password" placeholder="*********"/>
<input type="button" value="Login" id="check_user" style="cursor:pointer;" />
</body>
</html>
最佳答案
假设你已经添加了jquery库,你需要在DOM加载时附加事件,即在 DOM 就绪事件上:
$(function(){//document ready function
$("#check_user").click(function(){
alert("good");
});
});
关于javascript - jquery 不工作 onclick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28274439/