Question: At present Clicking on 3rd li in menu cause toggled class to be added/removed to the nav could any one tell me how to make it such that clicking on any li adds/removes toggle class to the nav 

```
<nav id="site-navigation" class="main-navigation">
    <ul>
    <li><a href="#content" >HOME</a></li>
    <li><a href="#workstop" >SERVICES</a></li>
    <li><a href="#test" >TESTIMONIALS</a></li>
    </ul>
</nav><!-- #site-navigation -->

```

associated jquery code:

```
 $(document).ready(function(){

container = document.getElementById( 'site-navigation' );
menuitem = container.getElementsByTagName( 'li' )[2];
menuitem.onclick = function() {
    if ( -1 !== container.className.indexOf( 'toggled' ) )
        container.className = container.className.replace( ' toggled', '' );
    else
        container.className += ' toggled';
};

```

Code as a fiddle:
<http://jsfiddle.net/yKbFk/11/>

Answer: 
As you're using jQuery already, use [`.toggleClass()`](https://api.jquery.com/toggleClass/), you can try following:

```
$(document).ready(function(){
    $(".main-navigation ul li").on("click",function(){
        $(this).closest("nav").toggleClass("toggled"); // toggle For nav as per question
        //$("#site-navigation").toggleClass("toggled") // you can do this also
    });
})

```
Use [toggleClass](https://api.jquery.com/toggleClass/) :

```
$( "#site-navigation li a" ).click(function() {
  $( this ).closest("nav").toggleClass( "toggled" );
});

```

Also, your id's could use some work. It's a bit redundant to use an id of site-navigation and a class of main-navigation for a `nav` element. I also suspect that you don't reuse that class at all and were just looking to cover both bases.

How about just:

```
<nav>
    <ul>
    <li><a href="#content" >HOME</a></li>
    <li><a href="#workstop" >SERVICES</a></li>
    <li><a href="#test" >TESTIMONIALS</a></li>
    </ul>
</nav>

```

And then :

```
$(document).ready(function(){
    $( "nav ul li " ).click(function() {
        $( this ).closest("nav").toggleClass( "toggled" );
    });
});

```