jQuery移动面板open()方法

jQuery移动面板open()方法

jQuery Mobile是一个JavaScript库,用于开发响应式网站和Web应用程序。它是建立在jQuery之上的。在这篇文章中,我们将使用jQuery Mobile的panel open()方法来打开一个面板。面板open()不接受任何参数。

语法:

$(".selector").panel( "open" );

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

CDN Links:

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

例子:下面的例子演示了如何使用open()方法来打开一个面板。

<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <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-2.1.3.js">
    </script>
    <script src=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js">
    </script>
  
    <script>
        function openPanel(){
            // Invoke the open method of panel
            $("#divID").panel("open");
        }
    </script>
</head>
  
<body>
    <div data-role="page">
        <div data-role="header" >
            <h1 style="color:green;">GeeksforGeeks</h1>
            <h3>jQuery Mobile Panel open method</h3>
        </div>
  
        <div role="main" class="ui-content">
            <center>
                <button onclick="openPanel();"
                        style="width:400px;"> 
                      Open Panel 
                </button>
            </center>
          </div>>
  
        <div data-role="panel" id="divID">
            <h3>GeeksforGeeks</h3>
            <p>This is a panel</p>
  
        </div>
    </div>
</body>
  
</html>

输出:

jQuery移动面板open()方法

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程