Home > Web Front-end > JS Tutorial > Summary of jquery methods to operate checkbox_jquery

Summary of jquery methods to operate checkbox_jquery

WBOY
Release: 2016-05-16 16:15:39
Original
1165 people have browsed it

The examples in this article summarize the jquery method of operating checkbox. Share it with everyone for your reference. The specific analysis is as follows:

Three ways for jquery to determine checked:

Copy code The code is as follows:
$("input").attr("checked"); //Version 1.6 Return: "checked" or "undefined", 1.5-return: true or false
$("input").prop("checked"); //16 :true/false
$("input").is(":checked"); //All versions: true/false

Several ways to write jquery assignment checked:

All jquery versions can be assigned like this:

Copy code The code is as follows:
$("input").attr("checked","checked");
$("input").attr("checked",true);

jquery1.6: 4 types of assignment of prop:

Copy code The code is as follows:
$("input").prop("checked",true) ;
$("input").prop({checked:true}); //map key-value pairs
$("input").prop("checked",function(){
Return true;//The function returns true or false
});
$("input").prop("checked","checked");

I hope this article will be helpful to everyone’s jQuery programming.

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