选项卡我相信开发过前端的同学都不陌生,有时候我们也把它叫做页签,在网站开发中我们经常把它作为导航栏来使用。Bootstrap和EasyUI都已经封装好了选项卡组件,但是今天我们还是想自己动手来实现自己的选项卡,它的大致效果如图:
本页面中有4个按钮和4个div,当用户选中按钮时,被选中的按钮背景色变黄,对应的红色背景div内容则显示出来,其他3个div则被隐藏,那么我们的页面代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>选项卡</title>
<style>
#box div {
height: 300px;
width: 300px;
display: none;
background-color: red;
}
.active {
background-color: yellow;
}
</style>
</head>
<body>
<div id="box">
<input type="button" value="按钮1" />
<input type="button" value=&