我有一个带有用html / js编写的叠加的模态弹出窗口,一切正常但如果用户标签足够,他们可以到达底层表单字段/按钮。有什么好办法阻止这种情况吗?
答案 0 :(得分:2)
这是一个粗略的想法,但我希望激发想法,而不是告诉你究竟该怎么做。我将使用伪代码和伪jquery代码的组合:
function showMymodaldExample() {
//Show modal dialog (mymodal) code goes here
//
//Then we bind an event
$(document).bind('mymodal.keydown', function(e) {
if ( currently focussed element is not a child of mymodal ) {
set the focus previous element
}
});
}
然后记得在销毁/隐藏对话框时取消绑定mymodal.keydown