from this topic:
How can I position an element next to user text selection?
i can get the left position from:
var obj = arrow_btn;
var left = top = 0;
do {
left += obj.offsetLeft;
top += obj.offsetTop;
} while (obj = obj.offsetParent);
console.log("left="+left);
console.log("top=" + top);
but I get in the console:
left=590
top=[object DOMWindow]
any comments on why I can’t get the Top?
Yes, “top” is an immutable property of the global object “window” that refers to the top frame (DOMWindow). Your code is equivalent to:
To correct it, just make sure top is a var;