我有一个元素位于初始元素之上.该元素不是初始元素的子元素.我正在捕获初始元素的mouSEOver事件.当鼠标光标在顶部元素上方时,我正在松开它
有没有办法禁用顶级元素获取鼠标事件?
我有一个解决方案,其中鼠标悬停的顶部元素触发mouSEOver(e)的初始元素,但这种解决方案可能无法在我的情况下工作.
谢谢!
==
例如,我稍微修改了一个jquery文档的例子.这里#region是初始元素,#region2是阻塞元素. #region3是#region的小孩,因此它不会阻止其鼠标悬停.
<!DOCTYPE html> <html> <head> <style> #region { width:220px; height:170px; margin;10px; margin-right:50px; background:yellow; border:2px groove; float:right; } #region2 { background-color: white; float:right; position: relative; right: -150px; top: 50px; width: 100px; height: 100px; border: 1px solid } #region3 { width:30px; height: 30px; background-color: brown; } p { margin:0; margin-left:10px; color:red; width:220px; height:120px; padding-top:70px; float:left; font-size:14px; } span { display:block; } </style> <script src="http://code.jquery.com/jquery-1.4.4.js"></script> </head> <body> <p> Try scrolling too. <span>Move the mouse over the div.</span> <span> </span> </p> <div id="region"><div id="region3"></div></div> <div id="region2"></div> <script> $("#region").mousemove(function(e){ var pageCoords = "( " + e.pageX + "," + e.pageY + " )"; var clientCoords = "( " + e.clientX + "," + e.clientY + " )"; $("span:first").text("( e.pageX,e.pageY ) - " + pageCoords); $("span:last").text("( e.clientX,e.clientY ) - " + clientCoords); }); </script> </body> </html>