How to get left position of an object.
Hi,
I need to get the left position of an object without to set it, without jquery.
This is the script I'm trying, but doesn't work:
__________________________________
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Set Left Position</title>
<style>
#MyObject{
width: 25%;
top: 100px;
left: 200px;
height: 200px;
background-size: cover;
background-repeat: no-repeat;
position: absolute;
background-color: goldenrod;
}
</style>
</head>
<body>
<div id="MyObject"></div>
<h4 id="ShowLeftText">My Left Position Text</h4>
<button onClick="ShowLeftButton();">Show Left Button</button>
<script>
function ShowLeftButton(){
var MyLeftValue = MyObject.style.left;
document.getElementById("ShowLeftText").innerHTML = "My Left value is: " + MyLeftValue;
}
</script>
</body>
</html>
___________________
Can you help me.
Thanks.
