Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery uncheck checkbox with name property

Tags:

html

jquery

On an HTML page, I have a checkbox with the name property. I can't uncheck it with the name attribute.

HTML :

<input type="checkbox" value="1" name="show_static_notify">

jQuery :

$("input[name='show_static_notify']:checkbox:not(:checked)");
like image 296
DolDurma Avatar asked Dec 11 '22 07:12

DolDurma


2 Answers

Use .prop()

$("input[name='show_static_notify']:checkbox").prop('checked',false);

Fiddle Demo

like image 187
Tushar Gupta - curioustushar Avatar answered Feb 14 '23 10:02

Tushar Gupta - curioustushar


what you are doing is to find the unchecked checkbox with given name

To uncheck the checkbox, use .prop()

$("input[name='show_static_notify']").prop('checked', false);
like image 27
Arun P Johny Avatar answered Feb 14 '23 12:02

Arun P Johny