点击哪个,哪个下面的颜色变化
2017-08-03 17:39
323 查看
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*{ font-size:16px; color:#333;}
ul,li{ list-style:none; margin:0; padding:0; border:0;}
a{ text-decoration:none; }
.wb{ width:1000px; margin:0 auto; }
.wb li{ float:left; width:10%; margin:0 2%; height:60px; line-height:60px; font-weight:bold; text-align:center;}
.clearfix{ clear:both;}
.wb li:hover{ border-bottom:2px solid #0070ba;}
.wb .current{ border-bottom:2px solid #0070ba;}
</style>
<script src="jquery.js"></script>
</head>
<body>
<div class="wb">
<ul>
<li>首页</li>
<li>钢轨</li>
<li>钢板</li>
<li>中厚板</li>
<li>关于我们</li>
<li>新闻</li>
<li>联系我们</li>
</ul>
</div>
<script>
$(function(){
$(".wb li:eq(0)").addClass(".wb current")
$(".wb li").click(function(){
$(this).addClass(".wb current")
.siblings().removeClass(".wb current")
})
})
</script>
</body>
</html>
显示效果为右图:
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*{ font-size:16px; color:#333;}
ul,li{ list-style:none; margin:0; padding:0; border:0;}
a{ text-decoration:none; }
.wb{ width:1000px; margin:0 auto; }
.wb li{ float:left; width:10%; margin:0 2%; height:60px; line-height:60px; font-weight:bold; text-align:center;}
.clearfix{ clear:both;}
.wb li:hover{ border-bottom:2px solid #0070ba;}
.wb .current{ border-bottom:2px solid #0070ba;}
</style>
<script src="jquery.js"></script>
</head>
<body>
<div class="wb">
<ul>
<li>首页</li>
<li>钢轨</li>
<li>钢板</li>
<li>中厚板</li>
<li>关于我们</li>
<li>新闻</li>
<li>联系我们</li>
</ul>
</div>
<script>
$(function(){
$(".wb li:eq(0)").addClass(".wb current")
$(".wb li").click(function(){
$(this).addClass(".wb current")
.siblings().removeClass(".wb current")
})
})
</script>
</body>
</html>
显示效果为右图:
相关文章推荐
- android Button 颜色的变化(点击,放开,点击不放)
- android imageButton 点击按钮前中后,按钮颜色的变化
- 按钮和文字点击后颜色变化
- 自定义Button被点击的颜色变化效果
- mootools设置点击全部文本框时变化颜色
- ListView中item点击的时候颜色变化
- 代码设置文本点击按下颜色变化
- 点击图片改变颜色变化
- android一个LinearLayout中具有几个控件,想要使那几个控件在LinearLayout被点击时,有颜色变化
- Android View的点击事件导致文字颜色变化的实现原理
- android按钮被点击文字颜色变化效果
- JavaScript实现GridView行交替与行选中颜色变化,缺点是加入分页和UpdatePanel后,点击下一页后,功能就消失了
- android 控件点击状态颜色变化
- textview中点击效果实现,比如点击textview中实现图片和文字的颜色变化(类似于button)
- android按钮被点击文字颜色变化效果
- android按钮被点击文字颜色变化效果
- ViewPager+Fragment滑动或者点击导航颜色变化
- 在AndroidStudio中,使用selector完成按钮点击颜色变化功能
- Android 按钮被点击文字颜色变化效果
- android按钮被点击文字颜色变化效果