javascript - Horizontal accordion plugin: working with each container individially -
javascript - Horizontal accordion plugin: working with each container individially -
i trying create jquery plugin, here finish code. question is: need alter in plugin work each container individual?
;(function ( $, window, document, undefined ) { // create defaults 1 time var pluginname = 'accordion', defaults = { propertyname: "value" }; // actual plugin constructor function plugin( element, options ) { this.element = element; this.options = $.extend( {}, defaults, options) ; this._defaults = defaults; this._name = pluginname; this.init(); } plugin.prototype.init = function () { activeitem = $("li").first(); $(activeitem).addclass('active'); $(".tab").click(function(){ $(activeitem).animate({width: "41px"}, 500); $(activeitem).removeclass('active'); $(this).parent().animate({width: "640px"}, 500); activeitem = $(this).parent(); $(activeitem).addclass('active'); }); }; $.fn[pluginname] = function ( options ) { homecoming this.each(function () { if (!$.data(this, 'plugin_' + pluginname)) { $.data(this, 'plugin_' + pluginname, new plugin( this, options )); } }); } })( jquery, window, document ); $(document).ready(function(){ $("#acor_1").accordion(); $("#acor_2").accordion(); });
javascript jquery plugins accordion
Comments
Post a Comment