Follow the jquery API three-screen _jquery

Source: Internet
Author: User
1. Filtration
EQ (index) Look at this function and the basis of: EQ seems to be the same (is actually the same)
For example, if we choose <div>1</div><div>1</div>, we can use $ ("div"). EQ (1) or $ ("Div:eq (1)")
To select the second div effect is the same

Hasclass (Class) is used to determine whether the current element contains a class this and is ("."). +class) is the same, let's take a look at what this function is for, it is an expression that checks the collection of the currently selected element, and returns true if at least one of the elements conforms to the given expression. The parameters inside the is (expr) are the parameters of the selector.

Filter (expr) is used to select a collection of elements with a matching expression, which is somewhat similar to the IS, except that is the returned bool, used to determine that the filter is used to narrow the range, the parameter in the filter can be a function, and the return value of the function is a bool type, The node is preserved when the true is returned. In fact, the object is to do a loop, and then delete the not. For example, there are <p class= "AA" >asdf</p><p>2343</p> the one that we chose Class AA to change his text to a text
$ ("P"). Filter (function () {return $ (this). Hasclass ("AA")}). Text ("Selected items")

Not (txpr) is used to delete the matching element, which is the same as the previous one: not ()
Slice (Start,[end]) Select a segment from start to end if there is no end
$ ("P"). Slice (0, 1), I always feel that the second variable of this function should be better than NUM, from which one, select the first Num.

2 Find
Add (expr) adds a match to an expression to the original object, which is a bit like a multiple selector such as $ ("#id,. cs")
Can also be written as $ ("#id"). Add (". cs") effect
Children ([expr]) gets a collection of all child elements
Contents () finds all child nodes within a matching element. If it is an IFRAME, find the contents of the document. This can be conveniently used to change the contents of an IFRAME, such as a text editor.
Find (expr) searches for content that matches a specified expression, which can also be implemented using selectors such as $ ("ul Li") can be written as $ ("ul"). Find ("Li")
Next (expr) searches for the element immediately following the sibling element, which has the a+b selector form, such as The $ ("Div+p") with the P tag following the Div, and of course $ ("div"). Next ("P")
Nextall () search for all subsequent sibling elements this and a~b are the same $ ("Div~p") and $ ("div"). Nextall ("P") is the same
Prev ([expr]) gets the previous one of the adjacent sibling elements just the opposite of this and next ()
Prevall ([expr]) gets all the elements in front of this and Nextall () just the opposite
Siblings ([expr]) This function should be the Nextall () and Prevall () and the

Offsetparent () returns the parent of the first element, why is the first element, this is parent () with JavaScript, but we use jquery, and we manipulate jquery objects, In many tutorials are stressed that we want to distinguish between the jquery object and JS object, in fact, the jquery object is an array of arrays, we should pay attention to the operation of the value of the array out of the use of want to use the first in the back price index [0] to get the first object.
(expr) Gets the parent element of all the elements, we already know that the jquery object is an array, then it may contain multiple nodes, so we have to find the parent node of the multiple nodes, which is to find a node that can contain all of them. It's like two people. One is Hubei, one is Henan, you have to look for his upper level, that is, they are all Chinese. Of course, you can also fill in a parameter inside parent (Hubei) then finally we got the node is Hubei.

3 Series
In series there are only two functions andself () and End ()
Andself () added to the current element by adding the previous selection, this explanation reads a bit around the mouth. Here is the chain of jquery operation. For example, you chose China-Hubei to get the Hubei this node and then you use Andself () to add China, this is useful for you want to operate the elements before you do not filter.
End () go back to the last "destructive" operation, what is destructive, that is, to a set of the operation in the second
For example, we said next (), here we know why we can use $ ("div+p") to complete the operation to write $ ("div"). Next ("P").

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.