Get element position in browser with JavaScript
If you use table cells as menu buttons and autosize them, this code finds the left position of element with id 'menubutton', and then places element with id 'menubody' to the same left position:
var mbtn = document.getElementById('menubutton').getBoundingClientRect(); var mbody = document.getElementById('menubody'); mbody.style.left = mbtn.left+'px';
Or using jQuery
var newLeft = $('#menubutton').offset().left; $('#menubody').css('left',newLeft);