jQuery offsetParent() Method Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The offsetParent() method is an inbuilt method in jQuery that is used to find the first positioned parent element in the DOM tree. Syntax: $(selector).offsetParent()Parameters: This method does not contain any parameter. Return Value: This method returns the first positioned parent element. The below example illustrates the offsetParent() method in jQuery: Example: html <!DOCTYPE html> <html> <head> <title>The offsetParent Method</title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <!-- jQuery code to show the working of this method --> <script> $(document).ready(function () { $("button").click(function () { $("p").offsetParent().css("background-color", "green"); }); }); </script> <style> #d1 { border: 1px solid black; width: 70%; position: absolute; left: 10px; top: 50px } #d2 { border: 1px solid black; margin: 50px; background-color: lightblue; text-align: center; } p { padding-left: 80px; font-weight: bold; } </style> </head> <body> <button>Submit</button> <div id="d1"> <div id="d2"> <!-- click on this paragraph --> <p>Welcome to GeeksforGeeks!</p> </div> </div> </body> </html> Output: Related Articles: jQuery | addBack() with ExamplesjQuery | addClass() with Examples Comment K kundankumarjha Follow Improve K kundankumarjha Follow Improve Article Tags : Misc Web Technologies JQuery jQuery-Methods Explore jQuery Tutorial 8 min read Getting Started with jQuery 4 min read jQuery Introduction 7 min read jQuery Syntax 2 min read jQuery CDN 4 min read jQuery SelectorsJQuery Selectors 5 min read jQuery * Selector 1 min read jQuery #id Selector 1 min read jQuery .class Selector 1 min read jQuery EventsjQuery Events 4 min read jQuery bind() Method 2 min read jQuery blur() Method 1 min read jQuery change() Method 2 min read jQuery EffectsjQuery animate() Method 2 min read jQuery clearQueue() Method 2 min read jQuery delay() Method 2 min read jQuery HTML/CSSjQuery addClass() Method 2 min read jQuery after() Method 1 min read jQuery append() Method 2 min read jQuery TraversingjQuery | Traversing 4 min read jQuery add() method 1 min read jQuery addBack() Method 2 min read Like