Show pageOld revisionsBacklinksExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== 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: <code javascript> var mbtn = document.getElementById('menubutton').getBoundingClientRect(); var mbody = document.getElementById('menubody'); mbody.style.left = mbtn.left+'px'; </code> Or using jQuery <code javascript> var newLeft = $('#menubutton').offset().left; $('#menubody').css('left',newLeft); </code> development/js/get_elem_pos.txt Last modified: 2019/10/31 09:04by 127.0.0.1