jquerymobile-可摺疊內容(Collapsible content)

來源:互聯網
上載者:User

標籤:

可能我們在開發中遇到過這樣的問題,我們只是看到一個題目或者簡單的介紹,然後一點擊會在下面展開對應的詳細的內容。在jqm中實現這個效果很簡單。下面給出一段例子代碼:

<!DOCTYPE html><html><head><title>Collapsible Content - 2</title><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" /><script src="http://code.jquery.com/jquery-1.7.1.min.js"></script><script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script></head><body><div data-role="page" id="first">    <div data-role="header">        <h1>Collapsible Test</h1>    </div>    <div data-role="content">        <div data-role="collapsible">            <h3>First</h3>            <p>                Hello World...            </p>        </div>        <div data-role="collapsible">            <h3>First</h3>            <p>                Hello World...            </p>        </div>        <div data-role="collapsible" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d">            <h3>First</h3>            <p>                Hello World...            </p>        </div>        <div data-role="collapsible" data-content-theme="c" data-iconpos="right">              <h3>First</h3>              <p>                Hello World again...              </p>          </div>    </div></div></body></html>

頁面顯示如下:第一個未點開,第二、三、四個都點擊開了。

第三個使用了data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d"修改icon。

第四個使用data-content-theme="c"修改顯示的主題,使其內容被帶有邊框的內容包圍。 data-iconpos="right"使icon顯示在右邊。

我們可以將所有帶有data-role="collapsible"屬性的div,包圍在一個<div data-role="collapsible-set">中,使其組成一個整體,但是這樣點擊其中一個的時候,其他的會自動關閉。這樣的顯示效果如下:

jquerymobile-可摺疊內容(Collapsible content)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.