---
title: "超简易jQuery选项卡切换插件"
author: "caiceclb"
date: "2010-07-28T15:21:38Z"
tags: []
categories: ["Web前端"]
slug: "jquery"
draft: false
lastmod: "2010-07-30T17:40:06Z"
id: 723422
url: "https://caiceclb.iteye.com/blog/723422"
---

```
/* 简单选项卡插件 */
;(function($){
    $.fn.TabSimple = function(c){
    	c = $.extend({
			tab: ".s-tab", //标题项
			con: ".s-con", //内容项
			curr: "curr",  //当前高亮的css类名
			event: "click" //触发的事件，jQuery所支持的所有事件
    	},c);
	    return this.each(function(){
	        var tab = $(this).find(c.tab);
	    	var con = $(this).find(c.con);
	    	tab.bind(c.event, function(){
	    		var i = tab.index($(this));
	    		tab.removeClass(c.curr); //或tab.find("." + c.curr).removeClass(c.curr)
	    		$(this).addClass(c.curr);
	    		con.hide().eq(i).show();
	    	});
		});	
    };
})(jQuery);
```