Analysis of the difference between jquery parent and parents_jquery
WBOY
Release: 2016-05-16 17:20:48
Original
1465 people have browsed it
It can be seen that the value of parent is very clear, which is the parent element of the current element; parents is the ancestor element of the current element. Examples are listed below:
$('p').parent() gets div2, div3, div4 $('p').parent('.a') gets div3 $('p').parent().parent() obtains div1, which is rather strange; however, the characteristics of the Jquery object itself determine that this is feasible. $('p').parents() gets div1, div2, div3, div4 $('p').parents('.a') gets div3 parent (exp) Usage: Get an element set containing the unique parent element of all matching elements.
Among them: this.parent() is the td in front of input this.parent().parent() gets tr this.parent( ).parent().parent() obtains table this.parent().next() obtains td adjacent to td. In the example:
Hello
Hello
$("p").parent() gets:
Hello
< ;p>Hello
object, because the parent tag of the p tag is div
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn