jQuery实现table选项卡
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery实现table选项卡</title>
<style>
button.active{
background: red;
}
div.active{
display: block;
}
div{
width: 100px;
height: 100px;
display: none;
border: 1px solid red;
}
</style>
</head>
<body>
<button class="active">aaa</button>
<button>bbb</button>
<button>ccc</button>
<div class="active">a的内容</div>
<div>b的内容</div>
<div>c的内容</div>
</body>
</html>
<script src="jquery-3.4.1.min.js"></script>
<script>
$('button').click(function () {
$('button').removeClass('active');
$('div').removeClass('active');
$(this).addClass('active');
$('div').eq($(this).index()).addClass('active');
})
</script>