使用JQuery,我需要编写一个函数,点击任意一个按钮(edit0,edit1)。 我有以下代码:JQuery在所有按钮上点击事件,ID以自定义文本开头
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$('[id^=edit]').click(function() {
alert("1111");
});
</script>
</head>
<body>
<button id="edit0" class="edit"> edit </button>
<button id="edit1" class="edit"> edit </button>
</body>
</html>
当我运行它,什么都不会发生上按一下按钮。 我试图取代脚本:
$('button[class="edit"]').click(function() {
alert('1111');
});
但结果是一样的。