如何禁用页面上的特定jQuery事件?
要禁用特定的jQuery事件,请使用jQueryoff()方法。您可以尝试运行以下代码以了解如何在页面上禁用特定的jQuery事件-
示例
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").on("click", function(){
alert("您点击了!");
});
$("button").click(function(){
$("p").off("click");
});
});
</script>
</head>
<body>
<p>Click me</p>
<p>Click above to generate an alert box. Click the below button to remove namespace, which won’t generate an alert box.</p>
<button>Remove Event</button>
</body>
</html>热门推荐
1 入学校简短祝福语
3 薛之谦祝福语简短
10 表达家人的祝福语简短
11 生日祝福语舅舅 简短独特
12 小红书生日祝福语简短
13 新婚祝福语大全简短经典
14 周二祝福语大全简短
15 生日祝福语短句简短霸气
16 高温早安祝福语简短精辟
17 儿子31岁祝福语简短
18 祝福语生日男朋友简短