单击关闭JQuery水平手风琴 [英] Making JQuery horizontal accordion close on click

查看:85
本文介绍了单击关闭JQuery水平手风琴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例: http://vincent-massaro.com/map/

当前,脚本允许您单击手风琴的一部分以将其打开,但是将其设置为在mouseleave上关闭。当我将mouseleave设置为.click时,它会感到困惑,并且不知道它处于什么状态。我想要创建它,以便您可以单击以将其打开,然后单击以关闭它,而不是mouseleave。控制它的代码在下面,完整的脚本在页面源代码中链接的haccordion.js中。如果有人可以帮助我修改此脚本,我将不胜感激!

Currently, the script allows you to click on a piece of the accordion to open it, but it is set to close on mouseleave. When I set the mouseleave to .click, it gets confused and doesn't know what state it is in. I want to make it so that you can click to open it, and click to close it, instead of mouseleave. The code controlling this is below, and the full script is in haccordion.js linked in the page source. If someone could help me modify this script, I would be very grateful! Thanks in advance.

$target.click(function(){
            haccordion.expandli(config.accordionid, this)
                    config.$lastexpanded=$(this)
  })
            if (config.collapsecurrent){ //if previous content should be contracted when expanding current
                    $target.mouseleave(function(){
                          $(this).stop().animate({width:config.paneldimensions.peekw}, config.speed)
  })
  }


推荐答案

尝试使用此

$('.accordion-item-header').click(function() {
    var item = $(this).parent().find('.accordion-item-body');
    item.toggleClass('open').animate({
        width:item.hasClass('open') ? 0: 100 
    }, 100).toggleClass('open');
});

这篇关于单击关闭JQuery水平手风琴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆