Return the left position of a <div> element:
alert(document.getElementById("myDiv").style.left);
<!DOCTYPE html> <html> <body> <div id="myDiv" style="position:absolute;left:255px;">This is a div element.</div> <button type="button" onclick="myFunction()">Return left position of div</button> <p id="demo"></p> <script> function myFunction() {/*from w w w .jav a 2s .c o m*/ document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.left; } </script> </body> </html>