Exploring the intricacies of the mousemove event when it comes to absolute elements.
To showcase my findings, I have created a demo on Codepen.
The challenge is to capture the mousemove event on the #main element without affecting any of its absolutely positioned children.
HTML:
<div id="main">
<div class="btn">Click Me</div>
</div>
<div id="output">
</div>
JS:
$(document).ready(function(){
$('#main').on('mousemove',function( e ) {
var message = "Mouse move ";
message += e.pageX + ", " + e.pageY;
$( "#output" ).html(message);
});
});