jQuery移动页面closeBtn选项

jQuery移动页面closeBtn选项

jQuery Mobile是一种基于网络的技术,旨在使响应式网站和应用程序在所有智能手机、平板电脑和桌面设备上都能访问。jQuery Mobile中的PageWidget负责维护jQuery Mobile框架中的一个项目。

在这篇文章中,我们将学习jQuery Mobile Page closeBtn选项。closeBtn选项是由对话框扩展促成的,它提供了对话框页面的关闭按钮,以返回到主页面。可以有3个不同的值。

  • left:按钮出现在标题栏的左边缘。
  • right。该按钮出现在标题栏的右边缘。
  • none : 关闭按钮将不会出现在对话框上。

语法closeBtn选项接收一个string值,并传递上述3个位置值中的一个,作为参数。默认值是left。

初始化closeBtn选项。

$("#gfgDialog").page({ closeBtn: "right" });
  • 初始化后获得closeBtn选项
var closeBtnOpt = $("#gfgDialog").page("option", "closeBtn");
  • 在初始化后设置closeBtn选项
$("#gfgDialog").page("option", "closeBtn", "right");

CDN链接。为jQuery Mobile项目使用以下CDN链接。

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

例子。在下面的例子中,我们提供了closeBtn选项的right位置。因此,关闭按钮出现在标题栏的右边。

<!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-1.11.1.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="gfgpage">
        <div data-role="header">
            <h1 style="color: green;">
                GeeksforGeeks
            </h1> 
        </div>
        <div data-role="main" class="ui-content">
            <h3>
                jQuery Mobile Page closeBtn Option
            </h3>
            <center>
                <a href="#gfgDialog" 
                   data-rel="dialog">
                    GeeksforGeeks dialog
                </a> 
            </center>
        </div>
    </div>
    <div data-role="page" id="gfgDialog">
        <div data-role="header">
            <h2>GeeksforGeeks</h2> 
        </div>
        <div role="main" class="ui-content">
            <p>Programming Tutorials Website</p>
            <ul>
                <li>Data Structures</li>
                <li>Algorithms</li>
                <li>Web Development</li>
            </ul>
        </div>
    </div>
    <script>
        (document).ready(function() {
            ("#gfgDialog").page({
                dialog: true,
                closeBtn: "right"
            });
        });
    </script>
</body>
  
</html>

输出:

jQuery移动页面closeBtn选项

jQuery移动页面closeBtn选项

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程