A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/HTMLElement/offsetLeft below:

offsetLeft · WebPlatform Docs

offsetLeft

Property of dom/HTMLElementdom/HTMLElement

Syntax
var result = element.offsetLeft;
element.offsetLeft = value;
Examples

This example uses the offsetLeft property to determine whether an object is in the user’s view.

<script type="text/javascript">
function isinView(element) {
    var oparent = element.offsetParent;
    var osleft = oID_1.offsetLeft;
    var cleft = oparent.clientWidth;
    if (osleft > cleft) {
        alert("Expand the window to see the paragraph!");
    }
}
</script>
...
<button onclick="isinView(this)">Click here</button>
...
<div id="oID_1" style="position: absolute; top:200px; left:1200px;">
...
</div>

View live example

Notes Remarks

You can determine the location, width, and height of an object by using a combination of the offsetLeft, offsetTop, offsetHeight, and offsetWidth properties. These numeric properties specify the physical coordinates and dimensions of the object relative to the object’s offset parent. For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location with CSSOM in Internet Explorer 9.

Syntax Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4