jQuery offsetParent Method


jQuery “offsetParent()” is used to get the closest ancestor element from set of the matched elements.


Syntax : jQuery offsetParent method

$(selector).offsetParent();

Note : It Accepts no parameter.

jQuery offsetParent() Method with demo Example

jQuery offsetParent() Method – Example 1

<script type="text/javascript">
         $(document).ready(function(){ 
              $( "#offsetExample" ).on( "click", function(event) {             
                 $("p").offsetParent().css("background","yellow");
              });
               
          });
</script>

Try it »


Advertisements

Add Comment

📖 Read More