Home >Web Front-end >JS Tutorial >How to ban div in jquery

How to ban div in jquery

藏色散人
藏色散人Original
2021-12-01 11:47:582864browse

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');

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!

Statement:
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