具有多个描述项的jQuery手风琴定义列表 [英] jQuery Accordion definition list with multiple description items

查看:91
本文介绍了具有多个描述项的jQuery手风琴定义列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法将 jQuery手风琴与具有多个描述项(dd的定义列表)一起使用).作者的示例只有dd个项目.

I can't seem to use jQuery Accordions with definition lists that have multiple desciption items (dd). The author's examples have only single dd items.

在下面的示例B2中,B3& C2显示onLoad,而不是像A1,B1&我想要的是C1.

In the example below B2, B3 & C2 show onLoad, rather than hide like A1, B1 & C1 as I would prefer.

我将如何实现?

jQuery('dl').accordion({ 
    event: 'click',     
    active: false, 
    animated: "bounceslide", 
    header: "dt" 
});​

<dl>

    <dt>A</dt>
    <dd>A1</dd>

    <dt>B</dt>
    <dd>B1</dd>
    <dd>B2</dd>
    <dd>B3</dd>

    <dt>C</dt>
    <dd>C1</dd>
    <dd>C2</dd>

</dl>

(实时jsFiddle版本)

推荐答案

  • demo: http://so.lucafilosofi.com/jquery-accordion-definition-list-with-multiple-description-items

$(function () {
    $('dt').on('click', function (e) {
        e.preventDefault();
        $(this).parent('dl').children('dd:visible').slideUp('slow');
        $(this).nextUntil('dt').filter(':not(:visible)').slideDown('slow');
    });
});

注意:

如果您想要多个部分

立即打开,不要使用手风琴

open at once, don't use an accordion

  • 手风琴所允许的范围不超过 一个内容面板将在 同时,这需要很多时间 努力做到这一点.如果你在找 对于允许多个控件的小部件 内容面板要打开,不要使用 这.通常可以用 几行jQuery代替 像这样: 参考: http://jqueryui.com/demos/accordion/
  • An accordion doesn't allow more than one content panel to be open at the same time, and it takes a lot of effort to do that. If you are looking for a widget that allows more than one content panel to be open, don't use this. Usually it can be written with a few lines of jQuery instead, something like this: REFERENCE: http://jqueryui.com/demos/accordion/

希望获得帮助! ;)

这篇关于具有多个描述项的jQuery手风琴定义列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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