How to ban div in jquery

藏色散人
Release: 2021-12-01 11:47:58
Original
2739 people have browsed it

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.

How to ban div in jquery

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');
Copy after login

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() { //...事件代码... }
Copy after login

The second method:

Use JQuery combined with CSS'pointer-events: none;' to achieve:

.p-not-click { pointer-events: none; }
Copy after login
// 禁用p $('#example').addClass('select-not-click'); // 启用p $('#example').removeClass('select-not-click');
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!