导航栏链接在可折叠模式下单击时不起作用

我相信错误所在的js代码

$("#navBartoggler").blur(function(event){
        var screenWidth=window.innerWidth;
        if(screenWidth<992){
            $("#navbarSupportedContent").collapse('hide');
        }
    });

导航栏的html代码段

<nav class="navbar navbar-expand-lg navbar-light" id="navbar-header">
  <a class="navbar-brand" id="brand" href="home.html" target="_self">
    <img src="home2.png" alt="company logo" id="logo-img">
  </a>
  <button id="navBartoggler" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
评论