Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to sho the active navigation ling using javascript

   <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
   <script>
   $(document).ready(function() {

            var CurrentUrl= document.URL;
            var CurrentUrlEnd = CurrentUrl.split('/').filter(Boolean).pop();
            console.log(CurrentUrlEnd);
            $( "#lu-ID li a" ).each(function() {
                  var ThisUrl = $(this).attr('href');
                  var ThisUrlEnd = ThisUrl.split('/').filter(Boolean).pop();

                  if(ThisUrlEnd == CurrentUrlEnd){
                  $(this).closest('li').addClass('active')
                  }
            });

   });
Comment

PREVIOUS NEXT
Code Example
Javascript :: sequelize select fields 
Javascript :: react comments 
Javascript :: node package.json type module 
Javascript :: javascript array randomizer 
Javascript :: js stringify 
Javascript :: js format string 2 digits 
Javascript :: how to get current date in express js 
Javascript :: blur effect javascript 
Javascript :: jquery var_dump array 
Javascript :: object values template literal js 
Javascript :: react algolia range slider 
Javascript :: es6 in nodejs 
Javascript :: csrf javascript 
Javascript :: npm hook form 
Javascript :: Routes in react-router-dom@6 and take the path by useLocation() hook 
Javascript :: mongoose check if user exists 
Javascript :: cancel an event in javascript 
Javascript :: angular img tag 
Javascript :: switch react router 
Javascript :: javascript replace ios apostrophe 
Javascript :: js object sort 
Javascript :: jquery slideshow autoplay 
Javascript :: axios react js 
Javascript :: flatten json python 
Javascript :: accepting form data node js 
Javascript :: sort array of objects in ascending order in js 
Javascript :: does pycharm support javascript 
Javascript :: add an object to index 0 array js 
Javascript :: for in javascript 
Javascript :: mui react outlined input helperText 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =