

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery parentsUntil() with Example
The parentsUntil() method in jQuery is used to return all ancestor elements between the selector and stop parameter value.
Syntax
The syntax is as follows −
$(selector).parentsUntil(stop,filter)
Above, the stop parameter is a selector expression, element or jQuery object. The filter parameter is a selector expression that narrows down the search for ancestors between the selector and the stops parameter.
Example
Let us now see an example to implement the jQuery parentsUntil() method −
<!DOCTYPE html> <html> <head> <style> div { width:600px; } .demo * { display: block; border: 2px solid yellow; color: blue; padding: 10px; margin: 10px; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("span").parentsUntil("div").css({"color": "blue", "border": "3px dashed blue"}); }); </script> </head> <body class="demo">great-great-grandparent <div>great-grandparent <ul>grandparent <li>parent <span>span</span> </li> </ul> </div> </body> </html>
Output
This will produce the following output−
- Related Questions & Answers
- jQuery focusin() with Example
- jQuery finish() with Example
- jQuery addClass() with Example
- jQuery focusout() with Example
- jQuery nextUntil() with Example
- jQuery appendTo() with Example
- jQuery closest() with Example
- jQuery dblclick() with Example
- jQuery fadeOut() with Example
- jQuery find() with Example
- jQuery first() with Example
- jQuery focus() with Example
- jQuery click() with Example
- jQuery blur() with Example
- jQuery innerWidth() with Example
Advertisements