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

How to uncheck checkbox in jquery?

青灯夜游
青灯夜游Original
2020-11-24 16:11:142359browse

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

2. Use attr() method

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

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!

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