当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


jQuery Mobile Toolbar toggle()用法及代码示例


jQuery Mobile 是一组基于 HTML5 的用户系统交互小部件工具箱,用于构建在 jQuery 之上的各种用途。它旨在构建可通过移动设备、选项卡和桌面访问的快速响应的网站。

在本文中,我们将使用 jQuery Mobile 工具栏toggle()方法来切换工具栏的可见性,也就是说,如果工具栏被隐藏,它将再次可见,如果工具栏可见,它将被隐藏。它是由固定工具栏延期。

用法:

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

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

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 工具栏 toggle() 方法。

HTML


<!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>

输出:

参考: https://api.jquerymobile.com/toolbar/#method-toggle



相关用法


注:本文由纯净天空筛选整理自vpsop大神的英文原创作品 jQuery Mobile Toolbar toggle() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。