javascript - ElementFromPoint for absolutely positioned elements? -
i'm using elementfrompoint find element pass mouse events after being captured ui mask. capture event @ mask, hide mask, use elementfrompoint(event.pagex, event.pagey) underlying element.
the problem elementfrompoint doesn't seem work @ absolutely positioned elements. gives first non-absolutely positioned parent. there way both absolutely , non-absolutely positioned elements, or have manual search through absolutely positioned children once parent elementfrompoint?
thanks
i tried , created code working absolutely fine have look
html
<div id="one">1</div> <div id="two">2</div> <div id="three">3</div> <div id="four">4</div> <div id="five">5</div> <div id="six">6</div>
css
div { width: 50px; height: 50px; background-color: black; color: white; margin-bottom: 30px; } #five{ position: absolute; left: 10px; top: 20px; background: red; }
js
$(document).ready(function(){ $(document.body).bind('click', function(e){ var elem = document.elementfrompoint(e.pagex, e.pagey); alert('you selected element id: ' + elem.id); }); });
Comments
Post a Comment