jQuery效果之tab选项卡及jQuery插件开发

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title>JQuery实例-标签页效果</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link type="text/css" rel="stylesheet" href="css/base.css" />
  <link type="text/css" rel="stylesheet" href="css/tab.css" />
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/HDtabs.js"></script>
<script type="text/javascript">
    $(function(){
        $('#tab').HDtabs();
    })
    
</script>
 </head>
 <body>
    <div id="tab" class="tab">
        <ul>
            <li>标签1</li>
            <li class="tabin">标签2</li>
            <li>标签3</li>
        </ul>
        <div class="content">
            <div class="contentin">我是内容1</div>
            <div>我是内容2</div>
            <div>我是内容3</div>
        </div>
    </div>

 </body>
</html>


CSS

.tab ul li {
 float: left;
 background-color: #868686;
 color: white;
 padding: 5px;
 margin-right: 2px;
 border: 1px solid white;
 cursor:pointer;
}
.tab ul li.tabin {
 background-color: #6E6E6E;
 border: 1px solid #6E6E6E;
}
.tab div.content {
 clear: left;
 background-color: #6E6E6E;
 color: white;
 width: 300px;
 height: 100px;
 padding: 10px;
}
.tab div.content div{
 display: none;
}

.tab div.content .contentin {
 display: block;
}


JAVASCRIPT

(function($){
    $.fn.HDtabs=function(settings){
        settings=jQuery.extend({
            "time":300
        },settings)
        $.fn.HDtabs.show($(this),settings);
    };
    $.fn.HDtabs.show=function($this,settings){
        var t='';
        $this.children('ul').children('li').mouseover(function(){
            var _this=$(this);
            t=setTimeout(function(){
                $this.children('ul').children('li').removeClass('tabin');
                _this.addClass('tabin');
                $this.children('.content').children('div').hide();
                $this.children('.content').children('div').eq(_this.index()).show();
            },settings.time);
        });
        $this.children('ul').children('li').mouseout(function(){
            clearTimeout(t);
        });
    }
})(jQuery)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值