Jquery notes on problems with checkboxes in projects

  • 2020-03-29 23:49:34
  • OfStack

About checkboxes

When I made a checkbox yesterday, I thought it would be easy at first, but I took it for granted that the main function is to click a button, for example, to select all one function, and then to select all the following lists.

Later on, I encountered many problems in practice. Note that in the input checkbox, it is not ok to judge with the normal attr property, because the checked value is checked, and only prop property can be changed!! See the API documentation, and later found in the baidu this has explained the official API, attach a prop in the jquery API address http://api.jquery.com/prop/, one of the examples is very classic, by judging is (" : checked ") compared to the attr, prop, worth a visit later changed the code;
$("#main-manage").on('click',"#selectAll", function(event) { 
$("#xunTable").find('input').not(":disabled").each(function(index, el) { 
$(this).prop('checked', 'true'); 
$(this).prop('checked', 'false'); 

Related articles: