In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to use end in jquery". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use end in jquery.
The role of end in jquery is to end the most recent filtering operation in the current chain and restore the set of matching elements to the previous state, using the syntax ".end ()".
This article operating environment: windows7 system, jquery3.2.1 version, DELL G3 computer
What is the use of end in jquery?
The jquery end () method ends the most recent filtering operation in the current chain and restores the set of matching elements to the previous state.
Grammar
.end ()
detailed description
Most jQuery traversal methods manipulate an instance of a jQuery object and generate a new object that matches a different set of DOM elements. When this happens, the new set of elements should be pushed into the stack held in the object. Each successful filter method call pushes the new element onto the stack. If we need the old set of elements, we can use end () to pop up the new collection from the stack.
Suppose there is a pair of very short lists on the page:
List item 1 list item 2 list item 3 list item 1 list item 2 list item 3
Examples
JQuery is mainly useful when making use of the chain attributes of jQuery (command chain). If we don't use the command chain, we usually call the previous object through the variable name, so we don't need to manipulate the stack. However, with end (), we can concatenate all the method calls together:
$('ul.first'). Find (' .foo'). Css ('background-color',' red') .end (). Find ('bar'). Css ('background-color',' green')
This command chain retrieves the items with the class name foo in the first list and sets their background to red. End () restores the object to the state it was before calling find (), so the second find () looks for the inner '.bar', not in the list, and sets the background of the matching element to green. The final result is that items 1 and 3 in the first list are set with a colored background, while the items in the second list remain unchanged.
At this point, I believe you have a deeper understanding of "how to use end in 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.