Home > Web Front-end > JS Tutorial > How to implement jquery checkbox if it is not optional

How to implement jquery checkbox if it is not optional

藏色散人
Release: 2023-01-03 09:23:16
Original
4495 people have browsed it

How to implement jquery checkbox as non-optional: First create a code sample file; then set the checkbox as non-optional through the "$(this).attr("disabled", false);" statement.

How to implement jquery checkbox if it is not optional

The operating environment of this article: Windows7 system, jquery1.2.6, Dell G3 computer.

How to make checkbox unselectable in jquery?

In jquery, if you want the checkbox to be unselectable, you need to disable the checkbox (checkbox) and add the disabled attribute to the checkbox.

Example:

$("input[type=checkbox]").each(function () {
        $(this).attr("disabled", false);
});
Copy after login

How to enable the disabled checkbox?

JQuery disables or starts the checkbox code

function changeCheckboxState(lx){
            if(true){//禁用
                $("input[type=checkbox]").each(function(){
                    $(this).attr("disabled",true);
                });
            }else{//启用
                $("input[type=checkbox]").each(function(){
                    $(this).attr("disabled",false);
                });
            }
        }
Copy after login

Recommended: "jquery video tutorial"

The above is the detailed content of How to implement jquery checkbox if it is not optional. 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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template