hover - Check if mouse is ABOVE an element jQuery -
i want check if mouse within visible area of div. know use following code:
$("#div").is(":hover"); in jquery.
however, there may div partially on #div, hover not work case.
i need check if mouse above element, regardless of elements on top of (preventing hover check).
if dont need actions applied element above div in question can apply pointer-events:none it. should solve problem , should able use $('#div').hover() fine.
test example.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>test</title> <style> div { width:50px; height:50px; position:absolute; } div#one { top:0; background:orange; } div#two { top:20px; background:blue; opacity:1; pointer-events:none; } </style> </head> <body> <div id="one"> </div> <div id="two"> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $(function(){ $('div#one').click(function(){ alert('one-clicked'); }); $('div#one').hover(function(){ console.log('one being hovered!') }); }); </script> </body> </html> all best, shalom
Comments
Post a Comment