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

jquery浮动的折叠面板控制表单显示隐藏插件

一款折叠面板控制插件,页面右侧可折叠的浮动面板,用户可以通过选中/取消选中相应的复选框来隐藏和显示表单元素。
  展开&收缩
 138  

jquery轻量级响应式反应快速的手风琴插件

一款响应迅速的手风琴特效,点击标题或加号,可自动展开响应内容,呈现缓慢展开显示动画。
  展开&收缩
 130  

js+css3响应式垂直手风琴展开收缩效果

一款绿色风格的原生js写的手风琴显示隐藏特效,打开后有关闭按钮,非常实用!
  展开&收缩
 162  

jquery鼠标hover抽屉式导航图片展开收缩代码

一款百叶窗图片展示特效,鼠标经过滑动打开图片,效果很惊艳!
  展开&收缩
 132  

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

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