Open In App
Related Articles

jQuery Mobile Page closeBtn Option

Improve Article
Save Article
Like Article

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


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 20 Jan, 2022
Like Article
Save Article
Similar Reads
Complete Tutorials