jQuery Mobile Pages

## jQ Mobile Tutorial

jQ Mobile HOME jQ Mobile Intro jQ Mobile Install jQ Mobile Pages jQ Mobile Transitions jQ Mobile Buttons jQ Mobile Icons jQ Mobile Toolbars jQ Mobile Navbars jQ Mobile Collapsibles jQ Mobile Grids

## jQ Mobile Lists

jQ Mobile List Views jQ Mobile List Content

## jQ Mobile Forms

jQ Mobile Form Basic jQ Mobile Form Inputs jQ Mobile Form Select jQ Mobile Form Sliders

## jQ Mobile Themes

jQ Mobile Themes

## jQ Mobile Events

jQ Mobile Events jQ Mobile Touch jQ Mobile Scroll jQ Mobile Orientation jQ Mobile Page Events

## Examples

jQ Mobile Examples

## References

jQ Data Attributes jQ Events jQ Icons

# jQuery Mobile Pages

« Previous
Next Chapter »

## Getting Started With jQuery Mobile

| Even though jQuery Mobile works on all mobile devices, it may have some compatibility issues on desktop computers (due to limited CSS3 support). For this tutorial, we recommend that you use the Google Chrome Browser for better reading experience.

## Example

<body>
<div data-role="page">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="content">
<p>I Am Now A Mobile Developer!!</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
Try it yourself »

Example explained:

- The data-role="page" is the page displayed in the browser
- The data-role="header" creates a toolbar at the top of the page (often used for title or search buttons)
- The data-role="content" defines the content of the page, like text, images, forms and buttons, etc.
- The data-role="footer" creates a toolbar at the bottom of the page
- Inside these containers, you can add any HTML elements - paragraphs, images, headings, lists, etc.

| The HTML5 data-* attributes are used throughout jQuery Mobile to create a "touch-friendly" and attractive look for mobile devices.

## Adding Pages in jQuery Mobile

In jQuery Mobile, you can create multiple pages in a single HTML file.

Separate each page with a unique id and use the href attribute to link between them:

## Example

<div data-role="page" id="pageone">
<div data-role="content">
<a href="#pagetwo">Go to Page Two</a>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="content">
<a href="#pageone">Go to Page One</a>
</div>
</div>
Try it yourself »

Note: The load time will be affected by web applications with a lot of content (i.e text, links, images, scripts etc). Use external files if you don't want to link pages internally:

<a href="externalfile.html">Go To External Page</a>

## Using Pages as Dialogs

A dialog box is a type of window used to show information or request input.

To create a dialog box that opens when a user taps on a link, add data-rel="dialog" to the link:

## Example

<div data-role="page" id="pageone">
<div data-role="content">
<a href="#pagetwo" data-rel="dialog">Go to Page Two</a>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="content">
<a href="#pageone">Go to Page One</a>
</div>
</div>
Try it yourself »
« Previous
Next Chapter »

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE