daweibo 2021-10-10 14:58 采纳率: 50%
浏览 121
已结题

a标签点击不了,点击跳转没有反应

找的一段代码,然后发现div里面的a标签点击不了,有帮忙解答下的吗。谢谢,谢谢


<!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>
  • 写回答

1条回答 默认 最新

  • Mattie chen 2021-10-10 15:10
    关注
    
       <div onclick="hideMenu();" style="border:#555 2px outset;padding:10px;display:none;" id="menu1" tabIndex=0>I am a Menu
    

    将onblur改为onclick

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月18日
  • 已采纳回答 10月10日
  • 创建了问题 10月10日