Return the position of a <h2> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:position

Description

Return the position of a <h2> element:

Demo Code

ResultView the demo in separate window

<!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>

<script>
function myFunction() {//from   w ww.  j a  va 2s. co m
    console.log(document.getElementById("myH2").style.position);
}
</script>

</body>
</html>

Related Tutorials