Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - If checkbox value="test" uncheck

I have been trying to use jQuery to uncheck the checkbox if value is = to a variable for instance "test" Example:

<input type="checkbox" name="cbname" value="test" checked="checked" />

Since this one has a value of test i would like it to be unticked, how could i do this?

thanks

like image 236
Sean Avatar asked Dec 17 '22 17:12

Sean


1 Answers

var val = 'test';
$('input:checkbox[value="' + val + '"]').attr('checked', false);
like image 198
BoltClock Avatar answered Jan 06 '23 03:01

BoltClock