Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

jQuery Mobile panel close() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

jQuery Mobile is a framework for creating websites and web apps that are accessible on devices of various screen sizes like mobiles, tablets, laptops, and desktops. In this article, we will use the jQuery Mobile panel close() method to close an already opened panel. The panel close() method does not accept any arguments.

 

Syntax:

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

Parameters: This method does not accept any arguments.

CDN Links: First, add jQuery Mobile to your project.

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

Example: In the example below, we first open the panel using the panel open() method, and then we invoke the panel close() method after 3 seconds to close the panel.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <meta name="viewport" content=
          "width=device-width, initial-scale=1">
  
    <link rel="stylesheet" 
          href=
    <script src=
    </script>
    <script src=
    </script>
  
    <script>
        function openPanel(){          
            $("#divID").panel("open");
  
            // Close the panel after 3 seconds
            setTimeout(() => {
                // The close() method
                $("#divID").panel("close");
            }, 3000);
        }
    </script>
</head>
  
<body>
    <div data-role="page">
        <div data-role="header" >
            <h1 style="color:green;">GeeksforGeeks</h1>
            <h3>jQuery Mobile Panel close() 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>


Output:

jQuery Mobile panel close() Method

Reference: https://api.jquerymobile.com/panel/#method-close


My Personal Notes arrow_drop_up
Last Updated : 06 Jan, 2022
Like Article
Save Article
Similar Reads
Related Tutorials