gpt4 book ai didi

jquery - 禁用除单个 div 之外的整个文档上的单击事件

转载 作者:行者123 更新时间:2023-12-01 02:44:14 25 4
gpt4 key购买 nike

我的 MVC 应用程序中有一个网页。像这样

<html>
<head>
</head>
<body>
<div id="1st_section"> Contents................... so on</div>
<div id="2th_section">Contents................... so on</div>
<div id="3th_section">Contents................... so on</div>
<div id="4th_section">Contents................... so on</div>
</body>
</html>

在浏览器中渲染此页面时,我们需要启用鼠标单击功能 <div id="1st_section"> Contents................... so on</div>仅此部分。除此部分外,整个网页中都应禁用鼠标单击事件。

您能建议可能的方法吗?

最佳答案

如果您有来自其他地方的点击处理程序,您可以unbind使用 * - 通用选择器:

$(function(){
$('*').unbind('click');
$('body > div#1st_section').bind('click', function(){
//bind event listener goes here
});

});

关于jquery - 禁用除单个 div 之外的整个文档上的单击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15941396/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com