Javascript drag-and-drop series Article 1 offsetParent attribute page 1/3

Source: Internet
Author: User

In the first article, let's talk about the offsetParent attribute in Javascript.
Supported browsers: Internet Explorer 4.0 +, Mozilla 1.0 +, Netscape 6.0 +, Opera 7.0 +, and Safari 1.0 +
Element. offsetParent
Summary
OffsetParent returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element. if the element is non-positioned, the root element (html in standards compliant mode; body in quirks rendering mode) is the offsetParent. offsetParent returns null when the element has style. display set to "none ".
Syntax
ParentObj = element. offsetParent
Parameters
· ParentObj is an object reference to the element in which the current element is offset.
Specification
DOM Level 0. Not part of specification.
Excerpted from the Mozilla Developer Center website
Translation:
Element. offsetParent
Summary
The offsetParent attribute returns an object reference. This object is closest to the element that calls offsetParent (the closest to the contained level) and is a container element that has been positioned by CSS. If the container element is not CSS located, the offsetParent attribute is referenced by the root element (in standard compatibility mode, html element, and body element in weird rendering mode. When the style. display of the container element is set to "none" (except for IE and Opera), The offsetParent attribute returns null.
Syntax
ParentObj = element. offsetParent
Variable
· ParentObj is an element reference. The offset of the current element is calculated.
Specifications
DOM Level 0. Not part of the Specification.

<! Doctype html public "-// W3C // dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd"> <ptml> <pead> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "/> <title> Untitled Document </title> </pead> <body onload =" offset_init () "> <p id =" sonObj "> test the OffsetParent attribute </p> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.