$(“div”, obj).not(“:first”).hide();
$(“ul li”, obj).bind(opts.switchingMode, function () {
if (clickIndex != $(“ul li”, obj).index($(this))) {
clickIndex = $(“ul li”, obj).index($(this));
$(“.tabsSeletedLi”, obj).removeClass(“tabsSeletedLi”).addClass(“tabsUnSeletedLi”);
$(this).removeClass(“tabsUnSeletedLi”).addClass(“tabsSeletedLi”);
var divid = $(“a”, $(this)).attr(“href”).substr(1);
$(“div”, obj).hide();
$(“#” + divid, obj).show();
};
});
};
})(jQuery);
接下来上插件样式:
body{background-color: black;}
.tabsDiv{width: 500px;height: 350px;margin-top: 0px;margin-left: 0px;}
.tabsDiv ul{width: 500px;height: 20px;list-style: none;background-color: black;margin-bottom: 0px;margin: 0px;padding: 0px;}
.tabsDiv div{width: 500px;height: 330px;background-color: white;}
.tabsSeletedLi{width: 100px;height: 20px;background-color: white;float: left;text-align: center;}
.tabsSeletedLi a{width: 100px;height: 20px;color: black;}
.tabsUnSeletedLi{width: 100px;height: 20px;background-color: black;float: left;text-align: center;}
.tabsUnSeletedLi a{width: 100px;height: 20px;color: white;}
最终效果图,你懂的:


原文:http://www.cnblogs.com/JohnStart/archive/2011/08/24/jQueryPlugin.html










