(Sort of a newbie question from someone that is more accustomed to how Flash/ActionScript works.)
Given a checkbox and jQuery click(), how do I do the following:
$('#myCheckBox').click (function(event) {
checkboxState = event.target.attr("checked");
// now do something with checkboxState
}
I.e., I want to get the checkbox checked attribute within the anonymous function because that’s the pattern that seems to make the most sense, however I don’t know how this can be done.
Thanks.
.attr()needs to be called on a jQuery object:or you could use
this:is(':checked')returns true/false depending on the state of the checkboxhttp://api.jquery.com/is/
http://api.jquery.com/checked-selector/