JQuery traversal element descendant and compatriot implementation method, jquery descendant
1. Traverse future generations
Children ()
The children () method returns all direct child elements of the selected element.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Find ()
The find () method returns the child element of the selected element, all the way down until the last child.
Selecter must be added to find (). If selecter is not added, it cannot be displayed.
Therefore, a selector such as find ("*") find ("span") must be added ")
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2. Traverse compatriots
Siblings ()
The siblings () method returns all the compatriot elements of the selected element.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Next ()
Next () The next compatriot element of the selected Element
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
NextAll ()
The nextAll () method returns all siblings of the selected element.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
NextUntil ()
The nextUntil () method returns all the following compatriot elements between two given parameters.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Prev ()
Prev ()
PrevAll ()
PrevUntil ()
Prev = previous
So the traversal is the first compatriot of the specified element. This effect is similar to next ().
3. Filter
First ()
The first () method returns the first element of the selected element.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Last ()
The last () method returns the last element of the selected element.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Eq ()
The eq () method returns the elements with the specified index number in the selected element.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Filter ()
The filter () method allows you to specify a standard. Elements that do not match this standard will be deleted from the set, and matched elements will be returned.
<script type="text/javascript">$(function(){$("#btn").click(function(){$("div p").filter("#p2").each(function(i, e) { $("#info").html($("#info").html()+"("+$(this).attr("id")+")"); }); });});</script>
Not ()
The not () method returns all elements that do not match the standard.
The not () method is opposite to the filter () method.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The JQuery traversal element descendant and compatriot implementation method above is all the content that I have shared with you. I hope to give you a reference, and I hope you can also provide more support for the customer's house.