Say I have the following sample:
<input name="Opt1" id="Opt1" type="checkbox" value="1" alt="1948" title="RQlevel1" src="2" checked="checked" onclick="levels();"/> <label style="cursor:pointer" for="OptID12851948">PADI Advanced Open Water</label>
<input name="Opt2" id="Opt2" type="checkbox" value="2" alt="1953" title="RQlevel2" src="" onclick="levels();"/> <label style="cursor:pointer" for="OptID19521953">PADI Rescue</label>
<input name="Opt3" id="Opt3" type="checkbox" value="3" alt="1957" title="RQlevel2" src="" onclick="levels();"/> <label style="cursor:pointer" for="OptID19521953">PADI Rescue2</label>
If I click PADI Advanced Open Water checkbox, which will then call the levels() JavaScript function, how can I programmatically uncheck this checked checkbox using jQuery?
I have tried the following but doesn’t work:
if ($("input[value='1']:checked").attr("checked")){
$("input[value='1']:checked").attr(“checked”, false);
}
Use
removeAttr:Or with recent versions of jQuery, you can use
prop: