When click the element which will be toggled , toggles itself

Guys when click the element which will be toggled element, it toggles itself.Why? Just dont get , maybe making a typo or forgot something, i do not know.Just made headache. Thanks for your help! FIDDLE

$(function() {
  $('#list li:nth-child(4) a').click(function() {
* {
  padding: 0;
  margin: 0;
  list-style: none;
  text-decoration: none;

.fixed-side-menu {
  position: fixed;
  left: 0;
  top: 0;
  width: 200px;
  height: 100%;
  background: #333;

#list li a {
  position: Relative;
  display: block;
  padding: 10px 0px;
  text-align: Center;
  font-size: 30px;
  color: #fff;

#list li a:hover {
  background: #367a8b;

#dropdown {
  background: #367a8b;

#dropdown li a {
  padding: 10px 0px;
  margin: 10px 0;
  display: block;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="fixed-side-menu">
  <ul id="list">
    <li><a href="#">HOME</a></li>
    <li><a href="#">ABOUT</a></li>
    <li><a href="#">CONTACT</a></li>
    <li><a href="#">FAQ</a>
      <ul id="dropdown">
        <li><a href="#">Facebook</a></li>
        <li><a href="#">Twitter</a></li>


You need to select only anchors which are direct child of specific li element (btw, you should select only li:nth-child(4) which is direct child of #list):

$('#list > li:nth-child(4) > a').click(function() {

Otherwise, you were including anchor in #dropdown too.


Need Your Help

Is this a drawback for Ajax live search or a issue with the server

php ajax

I have a live search bar on my website. Today I tried to check the site security. In the search bar I kept on inputting data (words for search) continously and after some time my server crashed and...