var Tabs = function(obj) { obj._$tabsPanel = $(obj.id + " .tabs-panel"); obj._$tabs = $(obj.id + " .tabs"); this.obj = obj; this._init(obj); }; $.extend(Tabs.prototype, { _init: function(obj) { var _that = this; obj._$tabs.on("click", "div", function(event) { var id = $(this).data("index"); _that.setCurrent(id); obj.clickAfter(id); }); obj._$tabs.on("click", ".ico-close", function(event) { var id = $(this).parent().data("index"); _that.del(id); event.stopPropagation(); }); }, add: function(data) { var $tabsPanel = this.obj._$tabsPanel, $tabs = this.obj._$tabs; this.obj._prevId = $tabs.children("div.current").data("index"); $tabs.children("div").removeClass("current"); $tabsPanel.children("div").hide(); $tabs.append('