In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to query the last element of jquery". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
In jquery, you can use the prev () method to query the previous element of a specified element, which returns the previous sibling of the selected element with the syntax of "$(selector) .prev (filter)"; "filter" is an optional parameter that, if set, narrows the search for the previous sibling.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
In jquery, you can use the prev () method to query the previous element of a specified element.
The prev () method returns the previous sibling of the selected element.
Sibling elements are elements that share the same parent element.
Note: this method returns only one element.
Syntax:
$(selector) .prev (filter)
Parameter filter: optional, which specifies a selector expression that narrows the search for the previous sibling element.
Example 1: returns the previous sibling of each element with the class name "start":
.siblings * {display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px; margin: 15px } $(document) .ready (function () {$("li.start"). Prev (). Css ({"color": "red") "border": "2px solid red"}) }) Ul (parent) li (sibling) li (last sibling of the li node with the class name "start") li ( Li node named "start") li (sibling node) li (sibling node)
Example 2: select the previous sibling of each element
$(document) .ready (function () {$("div"). Prev (). Css ("background-color", "yellow");})
This is a P element.
This is a title and is the previous sibling of the div element. This is a div element.
This is another P element.
This is a P element and is the previous sibling of the div element.
This is a P element in div.
This is the end of the content of "how jquery queries the previous element". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.