Keep navigation link active with jQuery

After clicking on any navigation link in navgation and whenever that page will be open then one active class will be added in that element.

$(document).ready(function(){
 var a = $('.navbar-nav a');
 a.each(function(){
   if(window.location.href == $(this).attr('href')){
     $(this).closest('li').addClass('active');
   }
 })
})

Shaharia is a professional software engineer with more than 10 years of experience in the relevant fields. Digital ad certified, cloud platform architect, Big data enthusiasts, tech early adopters.