Toggle a simple navigation in Javascript

前端 未结 3 698
时光取名叫无心
时光取名叫无心 2021-01-28 05:24

I want to have a very simple navigation menu. It has to be clickable. So when using this code

3条回答
  •  醉话见心
    2021-01-28 05:59

    Your code is a rather odd mix of plain JS and jQuery. I'd suggest using one or the other. Here's a simple version of your code using jQuery:

    $(function() {
      $('#navBtn').click(function() {
        $('#navContent').toggle();
      }); 
    });
    #navContainer {
      position: relative;
      display: inline-block;
    }
    
    #navContent button {
      display: block;
    }
    
    
    

提交回复
热议问题