Skip to content
Related Articles

Related Articles

jQuery Mobile Page closeBtn Option

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 20 Jan, 2022

jQuery Mobile is a web-based technology designed to make responsive websites and apps that are accessible on all smartphone, tablet, and desktop devices. PageWidget in jQuery Mobile is responsible for maintaining a single item in jQuery Mobile’s framework.

In this article, we are going to learn the jQuery Mobile Page closeBtn option. The closeBtn option is facilitated by the dialog extension, which provides the closing button of the dialog page to return to the main page. There can be 3 different values:

  • left: The button appears on the left edge of the titlebar.
  • right: The button appears on the right edge of the titlebar.
  • none: The close button will not appear on the dialog box

Syntax: The closeBtn option takes a string value and passes one of the above 3 position values, as a parameter. The default value is left.

Initialize the closeBtn option:

$("#gfgDialog").page({ closeBtn: "right" });
  • Get the closeBtn option after initialization

    var closeBtnOpt = $("#gfgDialog").page("option", "closeBtn");
  • Set the closeBtn option after initialization

    $("#gfgDialog").page("option", "closeBtn", "right");

CDN Links: Use the following CDN links for the jQuery Mobile project.

<link rel=”stylesheet” href=”” />
<script src=””></script>
<script src=””></script>

Example: In the below example, we have provided the closeBtn option with the right position. Hence, the close button appears on the right of the titlebar.


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" 
          content="IE=edge" />
    <meta name="viewport" 
                   initial-scale=1.0" />
    <link rel="stylesheet" href=
    <script src=
    <script src=
    <div data-role="page" id="gfgpage">
        <div data-role="header">
            <h1 style="color: green;">
        <div data-role="main" class="ui-content">
                jQuery Mobile Page closeBtn Option
                <a href="#gfgDialog" 
                    GeeksforGeeks dialog
    <div data-role="page" id="gfgDialog">
        <div data-role="header">
        <div role="main" class="ui-content">
            <p>Programming Tutorials Website</p>
                <li>Data Structures</li>
                <li>Web Development</li>
        $(document).ready(function() {
                dialog: true,
                closeBtn: "right"


jQuery Mobile Page closeBtn Option

jQuery Mobile Page closeBtn Option


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!