Javascript 如何将焦点返回到z索引较低的对象,尝试在贴图顶部创建一系列透明div
如果我有一个父div,它上面包含一个子div,我可以在不隐藏子div的情况下给父div焦点吗 我正在使用Google Maps API,并希望在其顶部绘制一个透明div网格以插入信息,但是,由于所有这些小div都位于地图顶部,我无法拖动地图 我确信我可以用API来做,但这有点离题,因为我想做这件事,不管我在做什么Javascript 如何将焦点返回到z索引较低的对象,尝试在贴图顶部创建一系列透明div,javascript,css,google-maps-api-3,jquery,Javascript,Css,Google Maps Api 3,Jquery,如果我有一个父div,它上面包含一个子div,我可以在不隐藏子div的情况下给父div焦点吗 我正在使用Google Maps API,并希望在其顶部绘制一个透明div网格以插入信息,但是,由于所有这些小div都位于地图顶部,我无法拖动地图 我确信我可以用API来做,但这有点离题,因为我想做这件事,不管我在做什么 <div style="position: relative; width: 100px; height: 100px;" id="wanttofocus"> &l
<div style="position: relative; width: 100px; height: 100px;" id="wanttofocus">
<div style="position: absolute; width: 100px; height: 100px;"
id="want_to_see_but_dont_want_to_focus_on">Some overlay information</div>
</div>
一些叠加信息
我正在使用JQuery,并在.focus()
上乱搞,但没有成功
谢谢 事实证明,您可以使用jQuery“passthru”事件:
$(document).ready(function(){
$('#want_to_see_but_dont_want_to_focus_on').bind('mousemove mousedown mouseup', function(e){
$("#wanttofocus").trigger(e); // passing thru the event
});
$('#wanttofocus').bind('mousemove mousedown mouseup', function(e){
$('.status').html(e.type + ' ' + e.pageX + ' ' + e.pageY);
});
});
我已经创建了一个JSFIDLE,可以随意玩了:你不能专注于任何一个div-only窗口对象、一个元素和输入、select、button、textarea、have focus事件。谢谢你帮我清理这些。