Friday, 12 March 2010

Accessing checkbox state using jQuery

Use the attr() function in jQuery to get the state of a checkbox

Example:
$("#checkboxid").attr("checked")

returns true or false

Also
$("#checkboxid").attr("checked", true)

sets the state of the checkbox to selected

No comments:

Post a Comment