jQuery UI手风琴中可能只有一个部分吗? [英] Is it possible to have only one section in jQuery UI Accordion?

查看:130
本文介绍了jQuery UI手风琴中可能只有一个部分吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想组织Web系统的结构和设计,因此,我决定使用jQuery的手风琴组件(效果很好),因为我不想用不必要的空间来打扰用户,因此用户可以决定是否要查看此信息.

I will like to organize the structure and the design of my web system, for this reason I decided for the accordion component of jQuery (which is working pretty good) because I don't want to disturb the user with unnecessary space, so the user can decide if he want to see or not this information.

我的问题是手风琴内部只有一个部分(此部分是一个组件面板),我无法折叠手风琴中的一个部分(至少我不知道如何操作).如果我添加另一部分是可能的,但是我只需要一个.

My problem is that I just have one section inside this accordion (this section is a panel of components) and I can not collapse one section in the accordion (at least I don't know how). If I add another section then is possible, but I just need one.

在这种情况下有人可以帮助我吗?

Can somebody help me in this case?

推荐答案

您应设置 为true表示可以一次关闭所有部分.除非您指定此选项,否则当您只有一个部分时,您将无法关闭它,因为默认情况下一个部分应该一直处于活动状态.

You should set collapsible to true to indicate that all the sections can be closed at once. Unless you specify this, when you only have one section you can't close it since one section should be active all the time by default.

如果您想首先折叠该部分,则将 active 设置为false

Set active to false if you want the section to be collapsed initially

$("#accordion").accordion({
  active: false,
  collapsible: true
});

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>


<div id="accordion">
  <h3>Section 1</h3>
  <div>
    <p>Mauris mauris ante, blandit et, ultrices a, suscipit eget. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio.</p>
  </div>
</div>

这篇关于jQuery UI手风琴中可能只有一个部分吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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