jQuery parents Method

jQuery “parents() Method ” is used to get all ancestors of the selected element.

Syntax : jQuery parents() method


filter : It is optional, A selector expression used to match(parent) the elements against.

jQuery parents Method Example

jQuery parents() Method Example

<script type="text/javascript">
              $( "#parentExample" ).on( "click", function(event) {             
                 $("p").parents().css("border","1px solid green");

Try it »


Add Comment

📖 Read More