JQuery1.9.1 the adjustment method of of prop for the checkbox

  • 2020-03-30 02:46:21
  • OfStack

In jquery version 1.8.x, our checkbox check and uncheck operations are as follows:

Decide whether to select


Set the selected and unselected states:


However, this method is handled differently in query1.9.1

IE10, Chrome,FF, for the selected state, the first $('#checkbox').attr('checked',true) can be implemented
But when the check is cleared by code, the next time it is checked by code $('#checkbox').attr('checked',true)
Checked ='checked' in the code, but there is no check.
IE8, IE6 under no problem.

Later, I investigated the relevant data and found that the attr('checked',true) was replaced by prop('checked',true).

Related articles: