jQuery实现选项卡

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			#box{
				margin-left: 100px;
				margin-top: 100px;
			}
			ul{
				list-style: none;
				width: 280px;
				height: 32px;
			}
			.lie>li{
				float: left;
				border: 1px solid gainsboro;
				height: 32px;
				width:70px;
				box-sizing: border-box;
				border-left: none;
				text-align: center;
				line-height: 32px;
				cursor: pointer;
			}
			.lie-list li{
				width: 280px;
				height: 200px;
				border: 1px solid gainsboro;
				box-sizing: border-box;
				border-top: none;
				display: none;
			}
			.lie>li a{
				text-decoration: none;
				font-family: "楷体";
				font-size: 24px;
				color:gray;
			}
			.active{
				background: deepskyblue;
			}
			/* 元素第一个子元素   css3*/
			.lie-list>li:nth-child(1){
				display: block;
			}
		</style>
		<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				$(".lie").on("click","li",function(){
					var index = $(this).index()
					$(this).parent().siblings().children("li:eq(" + $(this).index() + ")").show().siblings().hide();
					$(this).addClass("active").siblings().removeClass("active");
				});
			})
		</script>
	</head>
	<body>
		<div id="box">
			<ul class="lie">
				<li class="active">电影</li>
				<li>娱乐</li>
				<li>生活</li>
				<li>军事</li>
			</ul>
			<ul class="lie-list">
				<li>电影......</li>
				<li>娱乐......</li>
				<li>生活......</li>
				<li>军事......</li>
			</ul>
		</div>
	</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值