如果禁用点击事件你的意思是禁用的事件侦听器,然后尝试off
方法:
$(document).ready(function(){
$('#disable-button').on('click',function(){
$('#table1').off('click');
});
$('#table1').on('click',function(){
alert('click event happened');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="table1" border="1px">
<tr>
<th>Title1</th>
<td>Orange</td>
<th>Title2</th>
<td>Apple</td>
</tr>
<tr>
<th>Title3</th>
<td>Food</td>
<th>Title4</th>
<td>Fish</td>
</tr>
</table>
<button id="disable-button">Disable listener</button>
否则,很简单方法是使用纯CSS:
pointer-events:none
但既然你想这样做jQuery的,而不是:如果您使用的jQuery版本1.4.3+
:
$('selector').click(false);
如果不是:
$('selector').click(function(){ return false; });
请包括所有相关的代码 – qiAlex
CSS也许? 'pointer-events:none'虽然这将有助于了解如何以及何时附加要避免的事件处理程序 –