- jQuery Mobile 教程
- jQuery Mobile - 主頁
- jQuery Mobile - 概述
- jQuery Mobile - 設定
- jQuery Mobile - 網頁
- jQuery Mobile - 圖示
- jQuery Mobile - 過渡
- jQuery Mobile - 佈局
- jQuery Mobile - 控制元件
- jQuery Mobile - 事件
- jQuery Mobile - 表單
- jQuery Mobile - 主題
- jQuery Mobile - CSS 類
- jQuery Mobile - 資料屬性
- jQuery Mobile 有用資源
- jQuery Mobile - 面試問題
- jQuery Mobile - 快速指南
- jQuery Mobile - 有用資源
- jQuery Mobile - 討論
jQuery Mobile - 內部和外部面板
說明
可透過在href屬性中提供面板路徑來顯示內部和外部面板。
示例
以下示例描述如何在 jQuery Mobile 框架中使用內部和外部面板。
<!DOCTYPE html>
<html>
<head>
<title>External and Internal Panels</title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$( document ).on( "pagecreate", function() {
$( "body > [data-role = 'panel']" ).panel();
$( "body > [data-role = 'panel'] [data-role = 'listview']" ).listview();
});
$( document ).one( "pageshow", function() {
$( "body > [data-role = 'header']" ).toolbar();
$( "body > [data-role = 'header'] [data-role = 'navbar']" ).navbar();
});
</script>
</head>
<body>
<div data-role = "header" data-position = "fixed" data-theme = "a">
<h2>Header</h2>
</div>
<div data-role = "page">
<div role = "main" class = "ui-content">
<h2>This is first page.</h2>
<a href = "#page_one"
class = "ui-btn ui-btn-inline">Click here to open right panel</a>
</div>
<div data-role = "panel" id = "page_one" data-position = "right"
data-display = "overlay" data-theme = "b">
<ul data-role = "listview">
<li data-icon = "delete"><a href = "#" data-rel = "close">Close</a></li>
<li>New Zealand</li>
<li>England</li>
<li>South Africa</li>
</ul>
</div>
<div data-role = "footer" data-position = "fixed">
<div data-role = "navbar">
<ul>
<li><a href = "/jquery_mobile/src/jqm_external_internal_panel.html"
class = "ui-btn-active">Page One</a></li>
<li><a href = "/jquery_mobile/src/page2.html">Page Two</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
輸出
讓我們執行以下步驟,瞭解上面的程式碼是如何工作的:
將上面的 html 程式碼另存為jqm_external_internal_panel.html檔案,並儲存在伺服器根資料夾中。
以 https:///jqm_external_internal_panel.html 形式開啟此 HTML 檔案,系統將顯示以下輸出。
jquery_mobile_widgets.htm
廣告