鼠标点击a标签Menu1时,弹出一个DIV,当鼠标点击DIV外的地方时,弹出层就隐藏。但是div里面的a标签点击不了。
把onblur换成onclick后,a标签能点击了,但是点击其他位置,div的弹出层就不能隐藏了。
有帮忙解决下这个问题吗,让a标签那里能点击,也让div弹出层在div之外点击能隐藏。
谢谢了,谢谢。
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<body>
<a href="javascript:showMenu();void(0);">Menu1</a>
<div onblur="hideMenu();" style="border:#555 2px outset;padding:10px;display:none;" id="menu1" tabIndex=0>I am a Menu
<a href="http://www.baidu.com">这里点击a标签没有跳转</a>
</div>
<script>
function showMenu(){
document.getElementById("menu1").style.display="";
document.getElementById("menu1").focus();
}
function hideMenu(){
document.getElementById("menu1").style.display="none";
}
</script>
</body>
</html>