1

The dropdown menu which is being used is of bootstrap. The code is as below

<li id="changethis" class="dropdown">
 <a  href="#" class="dropdown-toggle" data-toggle="dropdown">LINK</a>
  <ul class="dropdown-menu">
   <li id="clickme"><a href="#">Link1</a></li>
   <li><a href="#">Link 2</a></li>
   <li><a href="#">Link 3</a></li>
  </ul>
 </a>
<li>

Jquery code looks like this

$(document).ready(function () {
 $('#clickme').on('click', function () {
    $('#changethis').removeClass('dropdown');
    $(this).addClass('dropdown open');
 });
});

On click of Link1, I wish to change the li class to dropdown open. I am not getting any error in my console, but the dropdown class is not changed.


Bootply Link

Coding Enthusiast
  • 3,865
  • 1
  • 27
  • 50
Amr
  • 81
  • 3
  • 15
  • Check out [event.stopPropagation()](https://api.jquery.com/event.stoppropagation/). That should be all you need. This will keep the link's parents from being notified of the event, thus keeping the dropdown open. You don't need to remove or add classes. Just remember to pass `event` into your function (You can name it whatever you want). – Jack May 14 '15 at 12:32