JQuery-Mobile在图标点击上展开/折叠?

时间:2012-05-14 11:38:05

标签: jquery-mobile

有人知道如何仅在可折叠div中的图标点击时实现展开/折叠吗?

2 个答案:

答案 0 :(得分:1)

尝试jQM的Collapsible content。您需要的只是将data-role="collapsible"添加到div中,例如:

<div data-role="collapsible">
   <h3>I'm a header</h3>
   <p>
      I'm the collapsible content. 
      By default I'm closed, but you can click the header to open me.
   </p>
</div>

答案 1 :(得分:1)

我发现了以下方式:

...
                collapsibleHeading.find(".ui-icon").bind("click", function (event) {
                    var type = collapsibleHeading.is(".ui-collapsible-heading-collapsed") ?
                                                                                "expand" :                "collapse";

                    collapsible.trigger(type);

                    event.preventDefault();
                });

如果您需要更多详情请告诉我。

相关问题