Q:

Trying toggle method to introduce new class on button click

I am trying to introduce new class for specific div element using nth-child() pseudo-class but it is not working! 
Am I doing something wrong? 
Note that menu, container, newClass are already defined in CSS section and I'm not showing them here. 
Here is what I am trying:

$(function() {
  $("button").click(function {
    $("div:nth-child(2)").toggleClass("newClass");
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>Toggle CSS</button>
<div class="container">
  <div class="menu">
    <lu>
      <li>option 1</li>
      <li>option2</li>
      <li>option 3</li>
    </lu>
  </div>
</div>

A:

There are lots of mistakes in your code.  Which div are you want to add a class newClass?  I think your code should be like this 

$(function() {
    $("button").on('click', function() {
        $(".menu").toggleClass("newClass");
    });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>Toggle CSS</button>
<div class="container">
  <div class="menu">
    <ul>
      <li>option 1</li>
      <li>option2</li>
      <li>option 3</li>
    </ul>
  </div>
</div>

