jquery轻量级带自定义动画回调的手风琴插件

所属分类: 网页特效-展开&收缩    2023-11-23 11:23:52

jquery轻量级带自定义动画回调的手风琴插件 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery轻量级带自定义动画回调的手风琴插件(共7个文件)

    • index.html

使用方法

(function($){
    $.accordiom = function (el, options) {
        // To avoid scope issues, use 'base' instead of 'this'
        // to reference this class from internal events and functions.
        var base = this;
        
        // Access to jQuery and DOM versions of element
        base.$el = $(el);
        base.el = el;
        
        // Add a reverse reference to the DOM object
        base.$el.data('accordiom', base);
        
        base.init = function () {
            base.options = $.extend({}, $.accordiom.defaultOptions, options);
            
            // Put your initialization code here
        };
        
        // Sample Function, Uncomment to use
        // base.functionName = function(paramaters){
        // 
        // };
        
        // Run initializer
        base.init();
    };
    
    $.accordiom.defaultOptions = {
        speed: 500,
        showFirstItem: true,
        autoClosing: true,
        openAll: false,
        buttonBelowContent: false,
        beforeChange: function () {},
        afterchange: function () {},
        onLoad: function () {}
    };
    
    $.fn.accordiom = function (options) {
        return this.each( function () {
            (new $.accordiom(this, options));
            
            // For some reason the default options weren't being extended so I'll do it manually
            /*if (!options) {
	            options = $.accordiom.defaultOptions;
            }*/
            options = $.extend({}, $.accordiom.defaultOptions, options);

            
            // Handy functions need access to the speed option
            $(this).data('accordiom-speed', options.speed);
            
            // Hide the content, but conditionally leave the first one open
            if (options.openAll) {
	            $(this).children('.accordionButton').addClass('on');
            } else {
	            if (options.showFirstItem) {
	                $(this).children('.accordionContent').not(':first').hide();
	                $(this).children('.accordionButton').first().addClass('on');
	            } else {
	                $(this).children('.accordionContent').hide();
	            }
            }
            
            // Fire the onLoad callback once all's set up
            if (options.onLoad) {
	            options.onLoad.call(this, this);
            }
            
            // Bind events to the buttons
            $(this).children('.accordionButton').on('click', function () {
            
				// Grab the container element (which would be used in the initial selector)
				var $selectorEl = $(this).parent('div');
				
				if (options.beforeChange) {
					options.beforeChange.call(this, this); // sends the clicked accordion button element
				}

				if ($(this).is('.on')) {
					//$selectorEl.children('.accordionContent').slideUp(options.speed);
					if (options.buttonBelowContent) {
						$(this).prev('.accordionContent').slideUp(options.speed);
					} else {
						$(this).next('.accordionContent').slideUp(options.speed);
					}
					$(this).removeClass('on');
				} else {
					if (options.autoClosing) {
						$selectorEl.children('.accordionContent').slideUp(options.speed);
						$selectorEl.children('.accordionButton').removeClass('on');
					} else {}
					
					if (options.buttonBelowContent) {
						$(this).prev('.accordionContent').slideDown(options.speed);
					} else {
						$(this).next('.accordionContent').slideDown(options.speed);
					}
					$(this).addClass('on');
				}
                
                if (options.afterChange) {
                    options.afterChange.call(this, this); // sends the clicked accordion button element
                }
            });
            
        });
    };
    
    
    // Function: show all accordion items
    $.fn.accordiom.openAll = function (el) {
        $(el).children('.accordionContent').slideDown($(el).data('accordiom-speed'));
    };
    
    // Function: hide all accordion items
    $.fn.accordiom.closeAll = function (el) {
        $(el).children('.accordionContent').slideUp($(el).data('accordiom-speed'));
    };
    
    // Function: open item n (zero indexed)
    $.fn.accordiom.openItem = function (el, n) {
        var nIndexCount = $(el).children('.accordionButton').length-1;
        if ((n < 0) || (n > nIndexCount)) { // Quick error check
            throw('Accordiom: No accordion item of index ' + n + ' exists');
        } else {
            $($(el).children('.accordionButton')[n]).trigger('click');
        }
    };
    

    
})(jQuery);

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 展开&收缩

jquery图片展开收缩特效代码

鼠标hover经过图片上,显示展开按钮,点击后展开显示完整图片。
  展开&收缩
 9264  0

jquery树形结构展开收缩折叠菜单插件

一款可复选框的折叠收缩菜单特效,可全部选中、取消选择以及选中指定菜单功能。
  展开&收缩
 9785  0

jquery可扩展的手风琴展开收缩动画特效代码

一款手风琴动画特效插件,响应式布局设计,点击标题横条即可切换,右侧图片同步切换。
  展开&收缩
 2269  0

jquery点击按钮滑动打开显示侧边栏特效代码

一款响应式滑动式侧边栏插件,点击按钮可展开显示边栏模块,点击空白处或关闭可隐藏。
  展开&收缩
 3271  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论