Bummer! You must be logged in to access this page.

Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Menu toggle

Hi I'm making a navbar with toggle function but instead of toggling when clicked it disappears any help please here is my code

.nav {
    background-color: #333;
    list-style-type: none;
    text-align: center;
    margin: 0;
}
.nav li {
    display: inline-block;
    border-right: 1px solid #fff;
}
.nav li a {
    text-decoration: none;
    font-size: 20px;
    color: #fff;
    padding: 14px 16px;
    font-family: 'helvetica neue', helvetica;
}

@media ( max-width: 600px ) {

    .nav {
        text-align: left;
    }
    .nav li {
        display: block;
    }
    .nav-btn {
        display: block;
        background-color: #333;
        color: #fff;
        font-size: 20px;
        text-align: center;
    }
    .nav-btn:before {
        content: "menu";
    }

}```

``` java script
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
      <script>
       $('span.nav-btn').click(function() {

        $('ul.nav').toggle ();
    });
      </script>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
      <script>
       $('span.nav-btn').click(function() {

        $('ul.nav').toggle ();
    });
      </script>

1 Answer

I worked it out my <span> class="nav-btn"</span> was on the wrong line :)