用jquery编写的tab插件

用jquery编写的tab插件

源码

$.fn.ss_tab = function (options) {
    var box = $(this);
    var btns = $(this).find("ul:first > li"); //console.log($(btns).length);
    var contents = $(this).find("ul").eq(1).children("li"); //console.log($(contents).length);

    $(btns).eq(0).addClass("active");
    $(contents).hide();
    $(contents).eq(0).show();

    $(this).find("ul:first > li").click(function () {
        $(this).addClass("active").siblings().removeClass("active");
        var index = $(btns).index($(this)); //console.log(index);
        //$(contents).hide();
        $(contents).eq(index).show().siblings().hide();
    });
};
原文地址:https://www.cnblogs.com/haiconc/p/4186713.html