首页 > 其他 > 详细

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

时间:2017-01-13 08:57:33      阅读:132      评论:0      收藏:0      [点我收藏+]

 

<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连接跳转并添加上背景色,

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!