jquery实现选项卡切换代码实例实现选项卡切换代码实例
选项卡在网页中很常见,可以说是必备的一个元素了,网上其实也有很多案例讲解选项卡的做法,各种炫酷。
写这篇文章,就是记录下自己的一个练手Demo了。
两张简陋的图。
主要逻辑就在于找到选项卡和内容框相对应的下标。
<html>
<head>
<meta charset="UTF-8">
<title>选项卡</title>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
</head>
<style>
.tab{width:400px;height:400px;border:1px solid red;}
.tab-menu{height:100px;width:400px;border:1px solid grey;}
.tab-menu ul{list-style:none;}
.tab-menu li{display:block;width:30%;float:left;border:1px solid blue;}
.tab-box div{width:400px;height:300px;border:1px solid #ff4200;display:none;}
/* 让第一个框显示出来 */
.tab-box div:first-Child{display:block;}
/* 改变选项卡选中时候的样式 */
.change{background:red;}
</style>
<script>
$().ready(function(){
评论0