- 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 - 關閉對話方塊
描述
將 data-close-btn = "right" 新增到對話方塊容器中,可以在右側設定關閉按鈕。預設情況下,當包含屬性 dialogue 時,關閉按鈕出現在對話的左側。如果您不需要對話方塊中的關閉按鈕,那麼可以將 data-close-btn = "none" 新增到對話方塊容器。
設定關閉按鈕文字
可以透過對話方塊的資料屬性來設定關閉按鈕文字。
那是一項重要的輔助功能,因為關閉按鈕文字可以修改為翻譯成不同的語言。
預設情況下,它顯示一個僅圖示的按鈕。
文字在螢幕上不可見,但螢幕閱讀器可以讀取它。
將 data-attribute data-close-btn-text 設定為從標記配置文字。
可將 $.mobile.dialog.prototype.options.closeBtnText 屬性設定為特定字串,並且透過繫結到 mobileinit 事件,可以為所有對話方塊進行配置。
示例
以下示例演示了 jQuery Mobile 中使用關閉對話方塊的操作。
<!DOCTYPE html>
<html>
<head>
<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>
</head>
<body>
<div data-role = "page" id = "page1">
<div data-role = "header">
<h2>Header</h2>
</div>
<div role = "main" class = "ui-content">
<a href = "#page2" class = "ui-shadow ui-btn ui-corner-all ui-btn-inline">
Close Button</a>
<a href = "#page3" class = "ui-shadow ui-btn ui-corner-all ui-btn-inline">
No Close Button</a>
</div>
<div data-role = "footer">
<h4>Footer</h4>
</div>
</div>
<div data-role = "page" data-dialog = "true" data-close-btn = "right" id = "page2">
<div data-role = "header">
<h1>Dialogs</h1>
</div>
<div role = "main" class = "ui-content">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s.</p>
<p><a href = "#page1" class = "ui-btn ui-corner-all">Back</a></p>
</div>
</div>
<div data-role = "page" data-dialog = "true" data-close-btn = "none" id = "page3">
<div data-role = "header">
<h1>Dialogs</h1>
</div>
<div role = "main" class = "ui-content">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s.</p>
<p><a href = "#page1" class = "ui-btn ui-corner-all">Back</a></p>
</div>
</div>
</body>
</html>
輸出
讓我們執行以下步驟,瞭解上面的程式碼如何工作 -
將上述 html 程式碼另存為伺服器根資料夾中的 closing_dialogs.html 檔案。
將此 HTML 檔案開啟為 https:///closing_dialogs.html,將顯示以下輸出。
jquery_mobile_pages.htm
廣告