Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <span id='11a' style='top:55px;' onmouseover="GetPos(this);">stuff</span>
- <span id='12a' onmouseover="GetPos(this);">stuff</span>
- document.getElementById('11a').style.top
- function getPos(el) {
- // yay readability
- for (var lx=0, ly=0;
- el != null;
- lx += el.offsetLeft, ly += el.offsetTop, el = el.offsetParent);
- return {x: lx,y: ly};
- }
- var x = el.offsetLeft, y = el.offsetTop;
- var yPositionOfNewElement = el.offsetTop + el.offsetHeight + someMargin;
- var left = $('.span').offset().left,
- top = $('.span').offset().top;
- $(document).ready(function(){
- // Alert the position with jQuery
- var position = $("#myDivInQuestion").position();
- alert('X: ' + position.left + ", Y: " + position.top );
- });
Add Comment
Please, Sign In to add comment