Home > Web Front-end > JS Tutorial > body text

How does jQuery determine whether a checkbox is checked? Is there any way

云罗郡主
Release: 2018-10-27 11:33:17
forward
3658 people have browsed it

The content of this article is about how jQuery determines whether the check box is checked? Is there any method that has certain reference value? Friends in need can refer to it. I hope it will be helpful to you.

The function implemented here is to assign a value to the input form when the check box is checked, and clear the form value when the check box is cancelled.

How does jQuery determine whether a checkbox is checked? Is there any way

Implementation source code: cyfID is the id of the check box

$("#cyfID").click(function(){ 
    var ischeck=$(this).attr("checked"); 
    if(ischeck==undefined){ 
        //清除输入框 
        alert(""); 
    }
    else{ 
        //给输入框赋值 
                 alert("qq"); 
    } 
});
Copy after login

The implementation principle is: when the check box is checked $(this).attr(" checked") is checked, and it is undefined when not checked.

The above is how jQuery determines whether a checkbox is checked? I hope you can gain something from all the methods. Please pay attention to the PHP Chinese website for more jQuery.

The above is the detailed content of How does jQuery determine whether a checkbox is checked? Is there any way. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:lvyestudy.com
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