Javascript DOM CSS Style right Property get

Introduction

Return the right position of a <div> element:

alert(document.getElementById("myDiv").style.right);

View in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="position:absolute;right:15px;">This is a div element.</div>

<button type="button" onclick="myFunction()">Return right position of div</button>

<p id="demo"></p>
<script>
function myFunction() {//from w ww . j  a va  2  s.  co m
  
document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.right;
}
</script>

</body>
</html>



PreviousNext

Related