I want to check whether checkbox is checked or not using jquery. I want to check it on checkbox’s onclick event.
<input type="checkbox" onclick="javascript:check_action();" id="Public(Web)" checked="checked" value="anyone" name="data[anyone]">
Is it possible? How?
Thanks.
First, don’t use
javascript:in event handler attributes. It’s wrong and only works because it happens to be valid JavaScript syntax. Second, youridis not valid. Parentheses are not allowed in theidattribute (in HTML 4 at least; HTML 5 lifts this restriction). Third, if you’re using jQuery it probably makes sense to use itsclick()method to handle theclickevent, although be aware that changing it to do that will mean that if the user clicks on the checkbox before the document has loaded then your script won’t handle it.