The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Retrieves a reference to the container object that defines the offsetTop and offsetLeft properties of the object.
Syntax
| JavaScript | |
|---|
Property values
Type: Object
the container object.
Remarks
Most of the time the offsetParent property returns the body object.
Examples
This example shows how to determine the position of a td object. Although the td object appears to the far right in the document, its position is close to the x-axis and y-axis, because its offset parent is a table object rather than the document body.
<html>
<head>
<title>Elements: Positions</title>
<script type="text/javascript">
function showPosition()
{
var oElement = document.all.oCell;
alert("The TD element is at (" + oElement.offsetLeft +
"," + oElement.offsetTop + ")\n" + "The offset parent is "
+ oElement.offsetParent.tagName );
}
</script>
</head>
<body onload="showPosition()">
<p>This document contains a right-aligned table.
<table align="right" border="1">
<tr>
<td id="oCell">This is a small table.</td>
</tr>
</table>
</p>
</body>
</html>
See also
- a
- abbr
- acronym
- address
- applet
- area
- article
- aside
- b
- bdo
- big
- blockQuote
- body
- br
- button
- caption
- center
- cite
- code
- col
- colGroup
- custom
- dd
- del
- dfn
- dir
- div
- dl
- dt
- em
- embed
- fieldSet
- figcaption
- figure
- font
- footer
- form
- frame
- frameSet
- head
- header
- hgroup
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=file
- input type=hidden
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- ins
- isIndex
- kbd
- label
- legend
- li
- listing
- map
- mark
- marquee
- menu
- nav
- nextID
- noBR
- object
- ol
- optGroup
- option
- p
- plainText
- pre
- q
- rt
- ruby
- s
- samp
- section
- select
- small
- span
- strike
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- tr
- tt
- u
- ul
- var
- xmp
- Measuring Element Dimension and Location with CSSOM in Internet Explorer 9
Send comments about this topic to Microsoft
Build date: 11/28/2012