When filtering, find the jQuery object corresponding to a dom object from the jQuery object that contains one or more dom objects, and then perform operations 1, $ (& quot; p & quot ;). eq (-2) Select the jQuery object corresponding to the last and second p elements from the searched p tag. Note that it is not a dom object. Here it must be consistent with ge... syntaxH
When filtering, we can find the jQuery object corresponding to a dom object from the jQuery object that contains one or more dom objects.
1,
$ ("P "). eq (-2) Select the jQuery object corresponding to the last and second p elements from the searched p tag. Note that it is not a dom object and should be separated from the get method.
The get method is to get the dom object and perform operations based on the html dom.
If you filter data from the forward direction, the index is based on www.2cto.com of 0.
2,
$ ("Li"). first () selects the jQuery object corresponding to the first li in jQuery corresponding to the searched li sequence ..
3,
$ ('Lil '). the last () principle is similar to that of finding the jQuery object corresponding to the last dom element, so that we can operate on it 4, $ (this ). hasClass ("protected") checks whether the current element has a specified class attribute. If yes, return true without false. The Code is as follows: $ (function (){
$ ("Li"). first (). click (function (){
If ($ (this). hasClass ("menu ")){
$ (This). hide (1000 );
}
});
});
Effect click item1 to hide... and slowly filter, 5, fileter .. you can filter out the non-conforming elements by passing the parameter $ ("li "). filter (". menu ") filter out the elements whose class attribute is menu $ (" li ") in li "). filter (", menu,: first") selects class = menu and the first li element... all parameters are selector strings. Multiple selector substrings must be separated by commas (,) $ ("li "). filter (function (I) {// select the li element that does not include the span sub-element in li.
Return $ ("span", this). length = 0;
}) 6, $ ("input [type = 'checkbox']"). parent (). is ("form") checks whether the parent element of checkbox is form7, $ ('lil '). has ('ul ') only retains ul elements 8, $ ("p") in li "). not ("# id") delete specified elements 9, $ ("li "). not ($ ("# menu") [0]) delete all elements 10, $ ("li") whose IDs are not menus from li "). the last left element of slice (-1) li $ ("li "). slice () selects 0-4 elements 11 and $ ("ul") in the li SET index "). children () Search for all subsets in ul $ ("ul "). children (". classname ") Select the element whose class attribute is classname In ul... $ ("ul "). children ("li") selects all li sets in ul 12, $ ("p "). find ("sp An ") Search for span elements from all p tags... the parameters follow the css selector 13, $ ("p "). next (". selected ") Get all the sets with class = selected attributes at the same level after the p element, 14, $ (" div: first "). nextAll (). addClass ("after", "one"); adds the after = one attribute 15, $ ("p") for all elements after the first div in the div set "). parent () returns the parent element of a paragraph $ ("span "). parents () Search for span's ancestor elements 16, $ ("p "). prev () takes the peer element 17 and $ ("div: last") in front of p "). prevAll (). addClass ("before"); get all div elements before the last element of the div .. and added class = before18, $ ("p "). add (document. getElementB YId ("a") in p, add the elements with id as a // 19, $ ("div "). find ("p "). andSelf (). addClass ("border"); select all div and div internal p and add class = border 20, $ ("iframe "). contents (). find ("body "). append ("I'm in an iframe! "); Find all the elements in the iframe label and add content to the inside... contents returns all nodes, 21, $ ("p "). find ("span "). end () searches for the jQuery object corresponding to p, and then finds span in p... finally, use end to destroy the previous operation... the returned result is the jQuery object corresponding to the p set .. The filtering of jQuery elements is now ....
Author: yue7603835