javascript - Setting "checked" for a checkbox with jQuery

Published: 18 March 2024
on channel: Code Samples
13
1

I'd like to do something like this to tick a checkbox using jQuery:
$(".myCheckBox").checked(true);

or
$(".myCheckBox").selected(true);

Does such a thing exist?
.prop(): https://api.jquery.com/prop
HTMLInputElement: https://developer.mozilla.org/en/docs...
.checked: https://developer.mozilla.org/en-US/d... .attr(): https://api.jquery.com/attr
the approach used by jQuery's unit tests prior to version 1.6: https://github.com/jquery/jquery/blob... .reset(): https://developer.mozilla.org/en-US/d...
version 1.6 release notes: https://blog.jquery.com/2011/05/03/jq...
.prop() documentation: https://api.jquery.com/prop


Watch video javascript - Setting "checked" for a checkbox with jQuery online without registration, duration hours minute second in high quality. This video was added by user Code Samples 18 March 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 13 once and liked it 1 people.