Return the position of a <h2> element:
alert(document.getElementById("myH2").style.position);
<!DOCTYPE html> <html> <body> <h2 id="myH2" style="position:absolute;left:100px;top:150px;"> This is a heading</h2> <button type="button" onclick="myFunction()"> Return type of position</button> <p id="demo"></p> <script> function myFunction() {/*ww w .j av a2 s . c o m*/ document.getElementById("demo").innerHTML = document.getElementById("myH2").style.position; } </script> </body> </html>