In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to realize the inverse method of jquery". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to achieve the reverse method of jquery"!
Jquery to achieve reverse methods: 1, import jQuery library; 2, set click events; 3, cycle to set other multi-check box selected state; 4, through the "! chkall;" way to achieve the identification variable can be reversed.
This article operating environment: windows7 system, jquery-2.1.4 version, Dell G3 computer.
How does jquery implement the inversion method?
Several methods of realizing full selection and reverse selection by using JQuery
As shown in the figure: the effect to be achieved is to click the full box to select all, and then click to uncheck all.
Method one idea: 1, import jQuery library, this can be downloaded online, is free and open source, 2, set class to fruit, set their properties through prop.
Method 1: jQuery code:
/ / define the identity. True means to select var chkall = true; $(function () {/ / all button to set the click event $("# btnAll") .click (function () {/ / 1), cycle to set other multi-check box check states, which are the same as the variables used in the logo: $(".check") .prop ("checked", chkall) / / 2. The identified variable is chkall =! chkall;})})
The second way of thinking: get all the checkboxes through the form filter and cycle through setting the checked property.
Method 2: jQuery code:
$(function () {/ / get the value of the full marquee var $checked = this.checked; / / get all the marquee $("input [class=fruit]") .each (function () {/ / the value of the checkbox is consistent with the value of the full marquee this.checked = $checked })
Finally, it is added that JQuery generally uses Attr to get the property, and sets the value of the property with prop.
At this point, I believe you have a deeper understanding of "how to achieve the inverse method of jquery". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.