Home >Web Front-end >JS Tutorial >A brief analysis of the problem of the checked attribute of jquery and checkbox_jquery

A brief analysis of the problem of the checked attribute of jquery and checkbox_jquery

WBOY
WBOYOriginal
2016-05-16 15:03:271578browse

1. After the page is loaded successfully, click to select or uncheck the checkbox. The checked attribute in the checkbox attribute will not change depending on whether the checkbox is selected or not

2. Use jquery's attr method to get checked in the onchange or onclick method in the checkbox. The value of the checked attribute that can be seen has nothing to do with whether it is hooked

3. Use document.getElementById("checkbox_id").checked to get the value and whether it is hooked, that is, what you see is what you get

4. The value obtained by using $("#checkbox_id").attr("checked") is consistent with the checked condition in , which is not what you see is what you get.

5. Use $("#checkbox:checked") to obtain hooked checkboxes

6. document.getElementById("checkbox_id").checked=true, the checked attribute in the control is not displayed, what you do is what you see

7. $("#checkbox_id").attr("checked", true), the checked attribute in the control is displayed, what you do is what you see, and the code will also change

The above brief analysis of the checked attribute of jquery and checkbox is all the content shared by the editor. I hope it can give you a reference, and I hope you will support Script Home.

Statement:
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