Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Mikey Neilson
seal-mask
.a{fill-rule:evenodd;}techdegree
Mikey Neilson
Front End Web Development Techdegree Student 12,642 Points

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>
Mikey Neilson
seal-mask
.a{fill-rule:evenodd;}techdegree
Mikey Neilson
Front End Web Development Techdegree Student 12,642 Points
 <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