Facts have proved everything. I tested it N times and found that what I said on the Internet and my previous understanding were all wrong. I wonder if you have noticed it. Let’s take a look at what most of the information on the Internet says
Transfer something from others: jquery determines whether the checkbox is selected in In the checkbox of html, if selected, there will be attribute checked="checked". If a checkbox is selected, alert($(#xxx).attr("checked")), the value of alert($(#xxx).attr("checked")), of the checkbox attribute "checked", will print out "true" instead of "checked"! If it is not selected, "undefined" will be printed.
//The above result is: if the checkbox is checked, "checked" will be printed, and if the checkbox is unchecked, "undefined" will be printed Experiments prove that it is wrong for Jquery to get checked value and print "true" Apply inferences: And it is found that Jquery gets checked checkbox and it will always be "checked". This is puzzling. If anyone If you know why, you can tell me, ha~~
//Pay attention to the red position. If the default checkbox is in the checked state, the test will find that the checkbox is checked. Removing it will only output "checked", indicating that you don't understand why Jquery behaves like this Solution, use document.get to get it:
//Selected is "true", unchecked is "false" If there is any mistake, please correct me . Questions searched on the Internet are all posted N times. Test it yourself to prove it.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn