HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

jQuery offsetParent() Method

jQuery HTML/CSS Methods jQuery HTML/CSS Methods

Example

Set the background color of the closest positioned parent element of the <p> element:

$("button").click(function(){
  $("p").offsetParent().css("background-color","red");
});

Try it yourself »

Definition and Usage

The offsetParent() method returns the first positioned parent element.

Tip: An element can be positioned with jQuery, or with the CSS position property (relative, absolute, or fixed).


Syntax

$(selector).offsetParent()


jQuery HTML/CSS Methods jQuery HTML/CSS Methods


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE