简体   繁体   English

移动视图中导航的问题

[英]problems with nav in mobile view

I am trying to have an icon that is going to show up in my mobile veiw where you can click show and hide the menu, right now my code doesnt work, it does not open at all 我正在尝试将一个图标显示在移动窗口中,您可以在其中单击显示并隐藏菜单,现在我的代码不起作用,它根本无法打开

my problem is trying to figure out id's and inputs here 我的问题是试图找出id和输入

not sure what I am doing wrong, could someone point me to the right direction please ? 不知道我在做什么错,有人可以指出我正确的方向吗? Thanks in advance 提前致谢

//this is what I have //这就是我所拥有的

<nav class="navMenu">
<input id="menu-icon" type="checkbox">
<label id="menu-icon" class="iconMenuLbl" for="menu-icon"></label>
<ul>

    <li>
        <a href=""><img class="navImg" src="media/Home-tall.png" alt=""></a>
    </li>
    <li>
        <a href="summary"><img class="navImg" src="media/My-Details-tall.png" alt=""></a>
    </li>
    <li>
        <a href="loans"><img class="navImg" src="media/My-Loans-tall.png" alt=""></a>
    </li>
    <li id="loggedin-box" class="">
        <form method="POST" action="login">
        <div>
            <strong>some name</strong>
        </div>
        <button style="padding:0px;" name="logout" type="submit">
        <img class="navImg" src="media/Sign-Out.png">
        </button>
        </form>
    </li>
</ul>
</nav>

//js file // js文件

$(function() {
  var menuVisible = false;
  $('#menu-icon').click(function() {
    if (menuVisible) {
      $('.navMenu').css({'display':'none'});
      menuVisible = false;
      return;
    }
    $('.navMenu').css({'display':'block'});
    menuVisible = true;
  });
  $('.navMenu').click(function() {
    $(this).css({'display':'none'});
    menuVisible = false;
  });
});

You have two ids sharing the same name. 您有两个共享相同名称的ID。 'menu-icon' try changing one of the ids to another name. “菜单图标”尝试将一个ID更改为另一个名称。 IDs should be unique. ID应该是唯一的。 -- ALSO move your input field out of the nav tag. -还可以将输入字段移出nav标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM