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
Post a Comment