Jquery / Javascript Solution for URL matches Href then add a Class

   <script> 

jQuery(document).ready(function($){ 
 var url      = window.location.href; 
  
  $('.service_list a').each(function(){
    var href = $(this).attr('href'); 
    if (url.indexOf(href) > -1) {
          //  alert("Yes!");
   $(this).addClass("active");
    } 
});
     
});

 </script>

Comments

Popular posts from this blog

dynamic create multiple ckeditor onclick event using jquery

get lat and long from city name using jquery

membership registration and login system in php