Jquery当前页面突出显示 [英] Jquery current page highlighted
本文介绍了Jquery当前页面突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的菜单
Here is my Menu
<table class="center-style-table">
<tr>
<td>
<ul class="subnav">
<li><a href="/Default.aspx">Hem</a></li>
<li><a href="/About.aspx">Om oss</a></li>
<li><a href="~/Apply.aspx">Ansök nu</a></li>
<li><a href="~/Conditions.aspx">Villkor</a></li>
<li><a href="~/Faqs.aspx">FAQs</a></li>
<li><a href="~/Contact.aspx">Kundtjänst</a></li>
</ul>
</td>
</tr>
</table>
这里我打电话给subnav。
here i am calling subnav.
<script type="text/javascript" charset="utf-8">
jQuery(function () {
window.jQuery('.subnav a').each(function () {
if (window.jQuery(this).attr('href') === window.location.pathname) {
window.jQuery(this).addClass('current');
}
});
});
</script>
这里我设定的风格
here i am setting the style
.subnav a.current {
border:1px solid white;
border-radius: 4px 4px 0 0;
cursor: pointer;
background-color: white;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 15px;
padding-top: 15px;
color: black;
font-weight: bold;
text-decoration: none;
}
我的问题是当我在页面加载时启动页面时,default.aspx设置为on首先加载页面,但是没有选择default.aspx,但是当我选择default.aspx时,它会被选中但我的其他网站aboutus.aspx当我选择那个页面时我的css不工作没有任何反应?
为什么?
my problem is when i start the page on page load the default.aspx is set to on page load first, but the default.aspx is not selected, but when i select the default.aspx it gets selected but my other site aboutus.aspx when i select that page my css dont work nothing happens?
Why?
推荐答案
这篇关于Jquery当前页面突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文