Home >Web Front-end >JS Tutorial >How to ban div in jquery
How to disable divs in jquery: 1. Use JQuery's off() method to disable divs; 2. Use JQuery combined with CSS's "pointer-events: none;" to disable divs.
The operating environment of this article: windows7 system, jquery3.2.1 version, DELL G3 computer
How to ban div in jquery?
Two ways to use JQuery to disable div
The first method:
Use JQuery's off () method:
$('#example').off('click');
If you want to re-enable it after using this method, you must re-add the binding event to '#example', that is:
$('#example').on('click', function() { //...事件代码... }
The second method:
Use JQuery combined with CSS'pointer-events: none;' to achieve:
.p-not-click { pointer-events: none; }
// 禁用p $('#example').addClass('select-not-click'); // 启用p $('#example').removeClass('select-not-click');
Personally recommend using the second one
Recommendation Study: "jquery video tutorial"
The above is the detailed content of How to ban div in jquery. For more information, please follow other related articles on the PHP Chinese website!