jQuery prevUntil Method


jQuery prevUntil Method : jQuery “prevUntil() Method ” is used to get all previous siblings between selector and selector-element ie. stop point where to stop matching previous siblings elements. Here is more info about how to use jQuery prevUntil Method efficiently. We will explain the prevUntill() method with simple example.


Syntax : jQuery prevUntil Method

Here is syntax of prevUntill method And Example-

$(selector).prevUntil(selector-element,filter);

selector-element It is stop point where to stop matching previous elements
filter : It is optional, A selector expression used to match(previous siblings) the elements against.

jQuery parentsUntil Method Example

jQuery prevUntil() Method – Example

<script type="text/javascript">
         $(document).ready(function(){ 
              $( "#prevUntilExample" ).on( "click", function(event) {             
                 $("span").prevUntil("li.level-two").css("border","1px solid green");
              });
               
          });
</script>

Try it »

In the above example the elements from span tag up to the class .level-two will be added bordered.

The above code will produce the following output –

Note : Below is image output only for demo click above “Try It” Button.

jQuery parentsUntil Method


Advertisements

Add Comment

📖 Read More