<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<title>JQuery 源码分析</title>
<style>
#div1 div{width: 200px;height: 200px;border: 1px solid #FF0000;display: none;}
.active{background: red;}
*{margin: 0;padding: 0;}
.tab:after{content: '';display: block;clear: both;}
.tab li{width: 150px;height: 30px;line-height: 30px;text-align: center;cursor: pointer;list-style: none;float: left;margin: 0 10px;background: #ABCDEF;border-radius: 5px;}
.tab li.active{background: #000;color:#fff;}
.content:after{content: '';display: block;clear: both;}
.content li{width: 460px;height: 300px;padding:20px;background: #f7f7f7;display: none;}
</style>
</head>
<body>
<div id="div1">
<input class="active" type="button" value="1" />
<input type="button" value="2"/>
<input type="button" value="3"/>
<div style="display: block;">11111111111</div>
<div>22222222222</div>
<div>333333333333</div>
</div>
<ul class="tab">
<li class="active">1</li>
<li>2</li>
<li>3</li>
</ul>
<ul class="content">
<li style="display: block;">111111111111</li>
<li>222222222222</li>
<li>333333333333</li>
</ul>
<script>
$(function(){
//jQuery 方法一
$('#div1').find('input').click(function(){
$('#div1').find('input').attr('class','');
$('#div1').find('div').css('display','none')
$(this).attr('class','active');
$('#div1').find('div').eq($(this).index()).css('display','block');
});
//jQuery 方法二
$('.tab').find('li').click(function(){
var index = $(this).index();
$(this).addClass('active').siblings().removeClass('active');
$('.content').find('li').eq(index).show().siblings().hide();
})
})
</script>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有