prop() property and should be used only to set the initial value of the checkbox. Yesterday I looked at how to get and set form element values with jQuery but didnt deal with checkboxes. Todays post looks at how to tell if an HTML form checkbox is checked or not checked with jQuery and then how to change it to be un/checked. How to check / unchecked a checkbox with jQuery. with the multiple attribute set), .val() returns an array containing the value of each selected option. By mkyong com/2013/06/ check-uncheck-checkbox-using-jquery.
htm. If you have a checkbox in a form you can use jQuery to read and set the data in the checkbox.This will return true if the checkbox is checked and false if left unchecked. Checking or Unchecking the Checkbox. Setting checked for a checkbox with jQuery? 688. Change the selected value of a drop-down list with jQuery. 3727. How to check whether a checkbox is checked in jQuery? 7303. You can check current amenities exists in Array using Array.some() and add checked attribute based on truthy. Var setChecked particularPropertyAmenity.some(function(e) return e.amenityName value.amenityName ) HtmlString Amenities: