im运行angular,bootstrap,jquery设置,由于某种原因,我似乎无法让jquery选择此按钮,单击该按钮不会执行任何操作:
$('#some_button').click(function(e) {
alert('testing');
});
<button id="some_button">some button</button>
看起来很简单,由于某种原因,它没有弹出警报消息...
编辑 抱歉,但这是我的错误。我将JavaScript封装在一个函数中,没有调用该函数。完全是我的错误。感谢您的光临。
答案 0 :(得分:0)
也许您忘记了包含脚本,或者忘记了包含jquery或angularjs的源代码,但这对我有用:
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<body>
<button id="some_button">some button</button>
<script>
$('#some_button').click(function(e) {
alert('testing');
});
</script>
</body>
</html>
答案 1 :(得分:0)
尝试一下
<script>
$(document).ready(function(){
$('#some_button').click(function(e) {
alert('testing');
});
});
</script>