2021-04-24

 HTML+CSS+jQuery+JavaScript实现选项卡功能

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<style type="text/css">
		#a{
			width: 410px;
			height: 80px;
			border:1px solid red;

		}
		.x{
			width: 40px;
			height: 40px;
			border:1px solid red;
			text-align: center;
			line-height: 40px;
			float: left;
			margin-top: 20px;
			margin: 20px 30px 0 30px;
		}
		#b{
			width: 410px;
			height: 400px;
			border:1px solid red;
			position: relative;
		}
		.n{
			width: 410px;
			height: 400px;
			border:1px solid red;
			position: absolute;
			top: 0;
			left: 0;
			display: none;
		}
		.xs{
			display: inline;
		}
	</style>
</head>
<body>
	<div id="a">
		<div class="x z0">1</div>
		<div class="x z1">2</div>
		<div class="x z2">3</div>
		<div class="x z3">4</div>
	</div>
	<div id="b">
		<div class="n r0 xs">内容1</div>
		<div class="n r1">内容2</div>
		<div class="n r2">内容3</div>
		<div class="n r3">内容4</div>
	</div>
	<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
	<script type="text/javascript">
		$(".x").each(function(i){
			$(this).click(function(){
				$(".x").css("border-bottom","1px solid red")
				$($(".z"+[i])).css("border-bottom","5px solid red")
			})
			$(this).click(function(){
				$(".n").removeClass("xs")
				$($(".r"+[i])).addClass("xs")
			})
		})
	</script>
</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值