码迷,mamicode.com
首页 > 其他好文 > 详细

首页导航点击A连接跳转并添加上背景色,

时间:2017-01-13 08:59:47      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:back   images   style   ges   href   script   idt   enter   line   

 

<style>
ul li {
float: left;
height: 50px;
width: 120px;
color: white;

text-align: center;
margin-left: 5px;
list-style-type: none;
}
a{
color:white;
text-decoration:none;
}
.menu{
height: 50px;
background: #0094ff;
line-height: 50px;
}
.bgcolor {
background: red;
}

</style>

 

<script>

$(document).ready(function () {
$(‘.menu li a‘).each(function () {
if ($($(this))[0].href == String(window.location))
$(this).parent().addClass(‘bgcolor‘);
});
})
</script>

 

<div class="menu">
<ul style="list-style-type: none;">

<li><a href="/Test/Home" title="网站首页" class="home">首页</a></li>
<li><a href="/Test/A" title="测试导航">A测试导航</a></li>
<li><a href="/Test/B" title="测试导航">B测试导航</a></li>
<li><a href="/Test/C" title="测试导航">C测试导航</a></li>

</ul>
</div>

 

 

技术分享

 

 

技术分享

首页导航点击A连接跳转并添加上背景色,

标签:back   images   style   ges   href   script   idt   enter   line   

原文地址:http://www.cnblogs.com/wxs-zxq/p/6281388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!