Menu is not working

Menu is not working
0

#1
<div id="stuck_container" class="stuck_container">
          <div class="container">
            <nav class="nav">
              <ul class="sf-menu">
                <li class="active"><a href="./">Home</a></li>
                <li><a href="AboutUs.php">About Us</a></li>
                <li><a href="Services.php">Services</a></li>
                <li><a href="Clients.php">Clients</a></li>
                <li><a href="Contacts.php">Contacts</a></li>
                <li><a href="WorkwithUs.php">Work with Us</a></li>
              </ul>
            </nav>
          </div>
        </div>

        <script>
          var selector = 'nav li';

          $(selector).on('click',function(){
$(selector).removeClass('active');
$(this.selector).addclass('active');
          })
        </script>

i use this code to a menu the problen is that when i click it the li that have the url that i click have too be selected by some css but it keep only mark the home li no meater were is it


#2

You have to format HTML code that you post here. Somehow the forum’s editor uses HTML tags to format content.

But I guess the culprit is this line:

$(this.selector).addclass('active');

I think you meant

$(this).addClass('active');
// ....... ^ look here; uppercase C

#3

Thanks, Kev - I edited the block to make it readable :slight_smile: