简单的jquery选项卡插件

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <style type="text/css">
        a {
            text-decoration: none;
        }
        ul, li, p {
            list-style-type: none;
            margin: 0px;
            padding: 0px;
            font-size: 12px;
        }
        #tabs {
            width: 600px;
            border: solid 1px #dddddd;
            margin: 50px auto;
            padding: 5px;
            overflow: hidden;
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
            border-bottom-left-radius: 4px;
            border-bottom-right-radius: 4px;
        }
        #tabs ul.tabs_header {
            display: block;
            position: relative;
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
            border: 1px solid #aaaaaa;
            background-color: #cccccc;
            padding: 5px 5px 0px;
            clear: both;
            height: 26px;
            line-height: 26px;
        }
        #tabs ul.tabs_header li {
            border: solid 1px #d3d3d3;
            border-bottom: 0 none !important;
            float: left;
            list-style: none outside none;
            margin: 0px 5px;
            position: relative;
            top: 1px;
            height: 24px; 
            /*此处要加上背景颜色,否则ie6下没有边框,(奇怪)有时在ie6下边框会不出现,刚刚又试了了一下居然又不出现问题了*/
            background-color: #F2F2F2; 
            /*圆角样式,较新版本的浏览器才支持,ff8.0支持,ie只有ie9支持*/
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
            padding: 0px 5px;
        }
        #tabs .tabs_header li a {
            color: #333;
        }
        #tabs .tabs_header li.hover {
            border: solid 1px #AAAAAA;
            background-color: #E4E4E4;
        }
        #tabs .tabs_header li.active {
            padding-bottom: 1px;
            margin-bottom: 0px;
            border: solid 1px #AAAAAA;
            background-color: #FFFFFF;
        }
        
        #tabs div.tabs_content {
            border: solid 1px #AAAAAA;
            padding: 10px;
            border-top: none;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div id="tabs">
        <ul class="tabs_header">
            <li><a href="###">选项卡一</a></li>
            <li><a href="###">选项卡二</a></li>
            <li><a href="###">选项卡三</a></li>
        </ul>
        <div class="tabs_content">
            <p>
                这是选项卡一的内容?<br />
                这是选项卡一的内容?<br />
                这是选项卡一的内容?<br />
                这是选项卡一的内容?<br />
                这是选项卡一的内容?<br />
                这是选项卡一的内容?<br />
                这是选项卡一的内容?
            </p>
        </div>
        <div class="tabs_content">
            <p>
                这是选项卡二的内容?<br />
                这是选项卡二的内容?<br />
                这是选项卡二的内容?<br />
                这是选项卡二的内容?<br />
                这是选项卡二的内容?<br />
                这是选项卡二的内容?<br />
                这是选项卡二的内容?
            </p>
        </div>
        <div class="tabs_content">
            <p>
                这是选项卡三的内容?<br />
                这是选项卡三的内容?<br />
                这是选项卡三的内容?<br />
                这是选项卡三的内容?<br />
                这是选项卡三的内容?<br />
                这是选项卡三的内容?<br />
                这是选项卡三的内容?
            </p>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#tabs").tabs();
        });
    </script>
    <script type="text/javascript">
        
        (function ($) {
            $.fn.tabs = function () {
                var content = this.find("div");
                var list = this.find("ul.tabs_header").find("li");
                content.hide();
                content.eq(0).show();
                list.eq(0).addClass("active");
                list.each(function (i) {
                    $(this).bind({
                        click: function () {
                            list.removeClass("active");
                            content.hide();
                            content.eq(i).css("display", "");
                            $(this).addClass("active");
                        },
                        mousemove: function () {
                            $(this).addClass("hover");
                        },
                        mouseout: function () {
                            $(this).removeClass("hover");
                        }
                    });
                });
            }
        })(jQuery);
		
    </script>
</body>
</html>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值