如何通过单击按钮切换jQuery Mobile手风琴? [英] How do I toggle the jQuery Mobile Accordion with a button click?

查看:66
本文介绍了如何通过单击按钮切换jQuery Mobile手风琴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建jQuery Mobile手风琴时,如何在单击按钮时打开手风琴的一部分?

When creating a jQuery Mobile Accordion, how do I get a section of the accordion to open when a button is clicked?

当用户单击搜索按钮时,我想将结果加载到第二个面板的列表中,折叠第一个面板,然后展开第二个面板.

When the user clicks the search button, I want to load the results into a list in the second panel, collapse the first and expand the second.

<div data-role="collapsible-set">

    <div id="filterContainer" data-role="collapsible" data-collapsed="false">
        <h3>Filters</h3>
        <p>controls to pick options</p>
        <a href="#" data-role="button" id="search">Search</a>
    </div>

    <div id="resultsContainer" data-role="collapsible">
        <h3>Results</h3>
        <p>list of results</p>
    </div>

<div>

推荐答案

实时示例:

HTML:

<div data-role="page" id="home" class="type-home"> 
    <div data-role="content">
        <div data-role="collapsible-set">

            <div id="filterContainer" data-role="collapsible" data-collapsed="false">
                <h3>Filters</h3>
                <p>controls to pick options</p>
                <!-- Either button syntax works -->
                <!-- <a href="#" data-role="button" id="search">Search</a> -->
                <input type="button" value="Search" id="search"/>
            </div>

            <div id="resultsContainer" data-role="collapsible" data-collapsed="true">
                <h3>Results</h3>
                <p>list of results</p>
            </div>

        <div>
    </div>
</div>

JS:

$('#search').click(function() {
    $('#resultsContainer').trigger('expand');
});

这篇关于如何通过单击按钮切换jQuery Mobile手风琴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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