jquery - Query string in url with : -


$("#menu a").each(function(index) {     if($.trim(this.href) == window.location.href) {         $('div', this).addclass("cc");     } }); 

this work when go

example.com/foo/foo/ 

when navigate second page example

example.com/foo/foo/p:2

this not work. how make query.

use .indexof function compare urls.

$("#menu a").each(function(index) {     var currenturl = window.location.href;     var ahref = $.trim(this.href);     if(currenturl.indexof(ahref) !== -1) {         $('div', this).addclass("cc");     } }); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -