In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces JQuery how to use check or uncheck to control checkbox control related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this JQuery how to use check or uncheck to control checkbox control article will have a harvest, let's take a look.
If we want to use JQuery to check or checkbox controls on uncheck pages, we might want to use the following code:
$('# chk-all'). On ('click', function () {
Var checked = $(this). Is (': checked')
$("input [type = 'checkbox'] [name='chk-att']"). Attr ('checked', checked)
})
Chk-all is a checkbox control, and we want to select all or deselect all by clicking on it. In the onclick event, first pass $(this). Is (': checked') to get the current checked state of the checkbox, and then check or uncheck the checkbox controls for all name='chk-att' on the page. The method used here is to change the value of the checked attribute, but this method does not always work. Sometimes you will see that the attribute value of the element has been changed, but the selected state has not changed. Try to change the attr () method to removeAttr () to uncheck it, but it still doesn't work!
The solution is to use the prop () function instead of the attr () function in the above code. Modify the above code as follows:
$('# chk-all'). On ('click', function () {
Var checked = $(this). Is (': checked')
$("input [type = 'checkbox'] [name='chk-att']"). Prop ('checked', checked)
})
This is the end of the article on "how JQuery uses check or uncheck to control checkbox controls". Thank you for reading! I believe you all have a certain understanding of "how JQuery uses check or uncheck to control checkbox controls". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.