最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jQuery实现选项卡功能(两种方法)
时间:2017-06-06 编辑:简简单单 来源:一聚教程网
效果图:
代码如下:
代码如下 | 复制代码 |
#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;}
22222222222
333333333333
$(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(); }) })
|
相关文章
- jquery几种不同样式的选项卡 06-30
- 基于jquery的选项卡效果 02-04
- jquery 选项卡效果 09-02
- jquery 选项卡插件 09-02
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31