當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


jQuery Mobile Toolbar destroy()用法及代碼示例

jQuery Mobile 是一種基於網絡的技術,用於製作可在所有智能手機、平板電腦和台式機上訪問的響應式內容。

在本文中,我們將使用 jQuery Mobile 工具欄 destroy() 方法來銷毀工具欄。 destroy() 方法從所選元素中完全刪除工具欄函數,並且該元素返回到其預初始化狀態。

用法:

$(".selector").toolbar("destroy");

參數:該方法不接受任何參數。

CDN 鏈接:首先,添加項目所需的 jQuery Mobile 腳本。

<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-2.1.3.js”></script>
<script src=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js”></script>

例子:此示例說明了 jQuery Mobile 工具欄destroy()方法。當我們單擊該按鈕時,它會從Divid “GFG” 和分區不再保留標題工具欄。它返回到其預初始化狀態。

HTML


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
    <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-2.1.3.js">
    </script>
    <script src=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js">
    </script>
    <script>
        function destroy() {
            $("#headerID").toolbar("destroy");
        }
    </script>
</head>
<body>
    <div data-role="page">
        <center>
            <h2 style="color:green">GeeksforGeeks</h2>
            <h3>jQuery Mobile Toolbar destroy() method</h3>
        </center>
        <div id="headerID" data-role="header">
            <h1>This is a header toolbar</h1>
        </div>
        <button onclick="destroy();">
            Destroy ToolBar
        </button>
    </div>
</body>
</html>

輸出:

參考:https://api.jquerymobile.com/toolbar/#method-destroy



相關用法


注:本文由純淨天空篩選整理自vpsop大神的英文原創作品 jQuery Mobile Toolbar destroy() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。