I have some tabs:
home
content
And I would like to add a class to the tab, when my URL contains the string ?dir.
So for example: if my URL is www.mypage.com/?dir=something then #contenttab should be active. And if the URL is for example only then
www.mypage.com#contenttab should not be active but #hometabshould be active.
My script is not working. #contenttabis always active and #hometab is never active.
Answer
Try checking with this :
if ( url.indexOf( '?dir' ) !== -1 ) { ... }
Or try with :
var url = location.search; // or location.href;
if ( url.indexOf( '?dir' ) !== -1 ) { ... }
No comments:
Post a Comment