General developer forum

Custom menu styling

Picture of Gratiela Dascalu
Custom menu styling

I'm trying to style the top custom menu to add a 'active' class on the clicked item and style it after with css. I did that with jquery, the code below:


         require(['jquery'], function($) { 

                $('.navbar-toolbar').on( 'click', '.nav-item', function() {


                     $( this ).addClass('active');




My problem is, the class is only added the moment before reloading the page and after is gone. Can you give me some advice on how to do this? Maybe with PHP?

Average of ratings: -