jQuery Mobile Popups
A popup is a very popular dialog that can be displayed over the page.
A popup can be used to display a piece of text, an image, a map, or other content.
To create a popup, use the and
Note:
Example
<
a href="#myPopup" data-rel="popup"
class="ui-btn ui-btn-inline ui-corner-all">Show popup
<
div data-role="popup" id="myPopup"
This is a simple popup
Try it »
If you need to add inner and outer padding to the popup, you can add the "ui-content" class in the
Example
Try it »
Closing a popup
By default, clicking outside the popup area or pressing the "Esc" key will close the popup. If you don't want clicking outside the popup to close it, you can add the data-dismissible="false" attribute (not recommended). You can also add a close button on the popup, using the data-rel="back" attribute on the button, and control the button's position with styles.
| Description | Example |
|---|---|
| Close button on the right | Try it |
| Close button on the left | Try it |
| Using the data-dismissible attribute | Try it |
Positioning popups
By default, the popup is displayed directly above the clicked element. To control the popup's position, you can use the data-position-to attribute on the click link that opens the popup.
Three ways to control popup position:
| Attribute values | Description |
|---|---|
| data-position-to="window" | Popup centered in the window |
| data-position-to="#myId" | Popup displayed over the specified #id element |
| data-position-to="origin" | Default. Popup displayed over the clicked element. |
Example
data-position-to="window" Window
data-position-to="#demo"> id="demo"
data-position-to="origin" Origin Try it » By default, popups have no transition effect. If you need one you can add a transition effect with the data-transition="value" attribute (jQuery Mobile Transitions):
data-transition="fade" Fade Try it » If you need to add a directional small border to the popup, you can use the data-arrow attribute and specify the value "l" (left), "t" (top), "r" (right) or "b" (bottom): The direction of the left border. Try it » You can make a popup into a standard dialog (header, content, and footer markup): Try it » You can display an image in a popup: Try it » You can use the data-overlay-theme attribute to add a background color behind the popup. By default the overlay background color is transparent. Use data-overlay-theme="a" to add a light background, and data-overlay-theme="b" to add a dark overlay background: There is a dark background behind me. Try it » Image popups often use a background overlay: Try it » Note: In the next chapter, you will learn how to use forms in popups.
Transition
All transition effect examples
Popup directional small border
Example
Popup dialog
Example
Header text..
Image popup
Example

Popup background overlay
Example
Example
