jQuery prevAll Method
jQuery “prevAll() Method ” is used to get all previous elements of the selected element.
Syntax : jQuery prevAll() method
$(selector).prevAll(filter);
filter : It is optional, A selector expression used to match the elements against.
jQuery prevAll Method demo Example
jQuery prevAll() Method – Example 1
<script type="text/javascript"> $(document).ready(function(){ $( "#prevExample" ).on( "click", function(event) { $(".fourth").prevAll().css("border","1px solid green"); }); }); </script> |
jQuery prevAll Method demo Example
jQuery prevAll() Method – Example 2
<script type="text/javascript"> $(document).ready(function(){ $( "#prevExample" ).on( "click", function(event) { $("p").prevAll(".para2").css("border","1px solid green"); }); }); </script> |
Advertisements