本文實例為大家分享了jquery實現(xiàn)可折疊的導(dǎo)航按鈕的具體代碼,供大家參考,具體內(nèi)容如下
功能:
當(dāng)功能較多時,創(chuàng)建可折疊分組導(dǎo)航按鈕。只需指定 data-role=" collapsible "創(chuàng)建可折疊面板
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>可折疊的導(dǎo)航面板</title> <!--使用名為viewport的meta值,其content指定自適應(yīng)設(shè)備的寬度--> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" > <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> </head> <body> <div data-role="page" id="pageone"> <div data-role="header"> <h1>圖書查閱系統(tǒng)</h1> </div> <!--創(chuàng)建一個可折疊的導(dǎo)航面板--> <div data-role="content"> <div data-role="collapsible" data-theme="e"> <h4>文學(xué)歷史</h4> <ul data-role="listview"> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >明代</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >宋代</a></li> </ul> </div> <!--顯示人文社科的可折疊面板--> <div data-role="collapsible" data-theme="b" data-collapsed="false"> <h4>人文社科</h4> <ul data-role="listview"> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >財務(wù)</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >心理</a></li> </ul> </div> <!--顯示計算機(jī)應(yīng)用的可折疊面板--> <div data-role="collapsible" data-theme="e"> <h4>計算機(jī)應(yīng)用</h4> <ul data-role="listview"> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >軟件開發(fā)</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >數(shù)據(jù)庫</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >移動開發(fā)</a></li> </ul> </div> </div> <div data-role="footer" data-position="fixed"> <h1>請單擊“+”按鈕進(jìn)行展開</h1> </div> </div> </body> </html>
代碼分析:
通過data-role=" collapsible "創(chuàng)建可折疊的div,再在其中通過 data-role=" listview "創(chuàng)建列表框
data-theme : 指定預(yù)定義樣式 (也可以使用樣式構(gòu)建器創(chuàng)建自定義樣式)
data-collapsed="false" : 表示默認(rèn)不折疊
效果圖:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點
疑難解答