jQuery Mobile Toolbar toggle()方法

jQuery Mobile Toolbar toggle()方法

jQuery Mobile是一套基于HTML5的用户系统交互widget工具箱,用于各种用途,建立在jQuery之上。它被设计用来建立快速和响应性的网站,可用于手机、标签和桌面。

在这篇文章中,我们将使用jQuery Mobile Toolbar toggle()方法来切换工具条的可见性,也就是说,如果工具条被隐藏,它将重新变得可见,如果工具条可见,它将被隐藏。它是由fixedToolbar扩展提供的。

语法:

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

参数:该方法不接受任何参数。

CDN链接:我们在项目中使用jQuery mobile之前,必须在代码中包含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 Toolbar toggle()方法。

<!DOCTYPE html>
<html lang="en">
  
<head>
    <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 toggle() {
            $("#GFG").toolbar("toggle");
        }
    </script>
</head>
  
<body>
    <div data-role="page">
        <center>
            <h2 style="color: green;">
              GeeksForGeeks
            </h2>
            <h3>jQuery Mobile Toolbar toggle() method</h3>
        </center>
        <div id="GFG" data-role="header">
            <h1>This is a header toolbar</h1>
        </div>
  
        <button onclick="toggle();">
          Toggle ToolBar
        </button>
    </div>
</body>
  
</html>

输出:

jQuery Mobile Toolbar toggle()方法

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程