Home > Web Front-end > H5 Tutorial > jquery traverses parent() method

jquery traverses parent() method

巴扎黑
Release: 2017-03-19 14:07:17
Original
1301 people have browsed it

[Introduction] jquery a traverses nodes-parent() method The parent([selector]) method returns a collection of parent elements of each matching element. Here selector is an optional parameter and is a selector expression used to filter parent elements. HTML code:

jquery a traverses nodes-parent() method

.parent([selector] ) method returns a collection of parent elements for each matching element.
The selector here is an optional parameter and is a selector expression used to filter parent elements.
HTML code:

jquery

jquery tutorial

jquery plugin

jquery code:

view sourceprint?1 $("p").parent().css tutorial("background", "green");//In this way, the background color of the parent element p of the three p's will turn green


Then pass in a parameter ".selected" to parent
jquery code:

view sourceprint?1 $("p").parent(".selected").css("background", " green");//In this way, the background color of the parent element p class of the three p's is "selected" will turn green

The above is the detailed content of jquery traverses parent() method. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template