Click here to Skip to main content
15,896,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I need to apply one css class based on the page i am in..All the divisions are in master page..

Can anyone help me with the code on how to find the url of the page and apply the class to that page using jquery?

Thanks.
Posted
Updated 3-Mar-14 0:44am
v2

Write all the codes in the Page load[^].
Get the url in javascript and apply your css in javascript :

Get current URL with JavaScript?[^]
How to apply CSS string using Javascript/jQuer[^]
 
Share this answer
 
v2
C#
var url = window.location.pathname;
if (url == "index.aspx")
{
   aHome.addClass("active");
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900