Home > Web Front-end > JS Tutorial > How to uncheck checkbox in jquery?

How to uncheck checkbox in jquery?

青灯夜游
Release: 2020-11-30 14:45:17
Original
2498 people have browsed it

Method: First select the checkbox element, and then use the prop() or attr() method to set the checked attribute value of the element to false, for example "$("input[type=' checkbox']").prop("checked",false);".

How to uncheck checkbox in jquery?

Related recommendations: "jQuery Tutorial"
The operating environment of this tutorial: windows7 system, jquery3.5 version, this method is applicable For all brands of computers.

Jquery method to uncheck checkbox:

1. Use prop() method

//设置不选中:
$("input[type='checkbox']").prop("checked",false);
//设置选中:
$("input[type='checkbox']").prop("checked",true);
Copy after login

2. Use attr() method

//设置不选中:
$("input[type='checkbox']").attr("checked",false);
//设置选中:
$("input[type='checkbox']").attr("checked",true);
Copy after login

For more programming-related knowledge, please visit: Programming Course! !

The above is the detailed content of How to uncheck checkbox 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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template