jQuery offsetParent() methodThe offsetParent() method in jQuery is used to return the closest positioned ancestor element. The element can be positioned with jQuery or by using the CSS position property (absolute, relative, or fixed). SyntaxThe offsetParent() method does not accepts any arguments. Let's see an illustration to understand the working of the offsetParent() method. ExampleIt is a simple example of using the offsetParent() method. In this example, there is a div element that contains a relatively positioned heading h5 and a paragraph element. We are using the offsetParent() method to get the first positioned parent of the p element. The heading h5 is the first positioned parent of the p element. So, on clicking the given button, the background color of the first positioned parent of p, which is heading h5, will get changed. Test it NowOutput After the execution of the above code, the output will be - ![]() After clicking the given button, the output will be - ![]()
Next TopicjQuery parents() method
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week