Home Archives About The-implementation-of-the-selected-state-of-the-node-js-routing Obtain the current URL with the JavaScript API window.location.href of the original soundtrack Intercepting the parameters of URL by split method You can pass arguments at the back of the route 123456789101112131415161718192021222324252627282930313233343536<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>navigation active</title></head><body> <nav > <ul id="navigation"> <li ><a href="/">Home</a></li> <li ><a href="/about">About</a></li> <li ><a href="/help">Help</a></li> <li ><a href="/contact">Contact</a></li> <li ><a href="/tems">Terms</a></li> </ul></nav><script type="text/javascript"> (function(){ var navigation = document.getElementById("navigation"); var navigation_node_li = navigation.getElementsByTagName('li'); var navigation_node_a = navigation.getElementsByTagName('a'); var index = 0; var url = window.location.href.split('?')[0].split('/').pop(); if(url){ for (var i=navigation_node_a.length; i--;) { if(navigation_node_a[i].href.indexOf(url) !== -1){ index = i; break; } } } navigation_node_li[index].className = 'active'; })();</script></body></html> Newer How-to-use-plupload-to-upload-plug-ins Older HTML5-pull-up-to-load-more