Reputation: 1447
var rect = document.getElementById("object").getBoundingClientRect();
console.log("rect.top, rect.right, rect.bottom, rect.left");
<div id="object"></div>
.object {
background: red;
width: 20px;
height: 20px;
position: relative;
top: 200px;
}
Super elementary question... I am trying to get the coordinates of #object, but the console returns rect.top, rect.right, rect.bottom, rect.left instead of the actual coordinates of #object. What am I missing?
JSFiddle: http://jsfiddle.net/tCraA/2/
Upvotes: 0
Views: 139
Reputation: 239291
You've logged a static string:
console.log("rect.top, rect.right, rect.bottom, rect.left");
You meant to write this:
console.log(rect.top, rect.right, rect.bottom, rect.left);
Upvotes: 1