由于许多原因,我需要禁用单击div
元素中的某些内容.例如,由于点击广告攻击.
尽管如此,我还是希望它是可见的.
考虑下面的片段:
<div class="ads">
something should be here, i do not want to be clicked
</div>
在那div
个地方怎么才能停用左键点击的功能呢?
由于许多原因,我需要禁用单击div
元素中的某些内容.例如,由于点击广告攻击.
尽管如此,我还是希望它是可见的.
考虑下面的片段:
<div class="ads">
something should be here, i do not want to be clicked
</div>
在那div
个地方怎么才能停用左键点击的功能呢?
可以使用的CSS属性是:
pointer-events:none
!IMPORTANT Keep in mind that this property is not supported by Opera Mini and IE 10 and below (inclusive). Another solution is needed for these browsers.
jQuery METHOD If you want to disable it via script and not CSS property, these can help you out: If you're using jQuery versions 1.4.3+:
$('selector').click(false);
If not:
$('selector').click(function(){return false;});
你可以用101(Documentation)次点击re-enable次
Note that pointer-events
overrides the cursor
property, so if you want the cursor to be something other than the standard , your css should be place after pointer-events
.