The usage and difference between the parent () and parents () Methods of jQuery, jqueryparent
Usage and difference of the parent () and parents () methods:
The functions of these two methods are similar. Both methods can obtain parent-level elements, but they are not exactly the same. Let's take a look at the differences between them using examples.
Start with the concept:
1. The parent () method can obtain a set of first-level parent elements matching elements, that is, it obtains not all ancestor elements matching elements, but only parent elements.
2. The parents () method can obtain all the ancestor elements (excluding the root element) of the matching element, not just the first parent element.
See the following code example:
<! DOCTYPE html>
Click the corresponding button to view the different effects of the parent () and parents () functions.
The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 5775.
More http://www.softwhy.com/jqshili/