var divPosition = $('div').position();
console.log('X: ' + divPosition.left + ", Y: " + divPosition.top");
So I can get the
y position of this div.
top but it's a square div on the page. I'm also tracking a section tag that flies around the page, I want to basically do
if (_thesectiontag_.left == _thesquarediv_.left || _thesectiontag_.top == _thesquarediv_.top) ... do something so if the
section tag is within the div coordinates on the page do something.
But I need to get the full dimensions of the square to be able to do that. I'm a bit lost on where to start and how to go about it.
Can anyone offer some help? Thank you!
Use this two code :
For the Width and Height includes padding :
var Height = document.getElementById('square').clientHeight; var Width = document.getElementById('square').clientWidth;
For the Width and Height includes padding, scrollBar and borders :
var Height = document.getElementById('square').offsetHeight; var Width = document.getElementById('square').offsetWidth;