如何使用jquery基于url将css类应用于母版页? [英] How to apply a css class to master page based on url using jquery?

查看:80
本文介绍了如何使用jquery基于url将css类应用于母版页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要根据我所在的页面应用一个css类。所有部门都在母版页中..



任何人都可以帮我找到如何找到页面网址的代码,并使用jquery将该类应用到该页面吗?



谢谢。

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.

推荐答案

写下页面加载 [ ^ ]。

在javascript中获取网址并在javascript中应用你的css:



使用JavaScript获取当前网址? [ ^ ]

如何使用Javascript / jQuer应用CSS字符串 [ ^ ]
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[^]


var url = window.location.pathname;
if (url == "index.aspx")
{
   aHome.addClass("active");
}


这篇关于如何使用jquery基于url将css类应用于母版页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆