jQuery Mobile Pages
Getting started with jQuery Mobile
|
| Although jQuery Mobile is compatible with all mobile devices, it is not fully compatible with PCs (due to limited CSS3 support).
为了更好的阅读本教程,建议您使用 Google Chrome 浏览器。 |
| --- | --- |
Example
data-role="header"
Welcome to my homepage
data-role="main" class="ui-content"
I am a mobile developer now!!
data-role="footer"
Footer text
Try it »
Example analysis:
- data-role="page" is the page displayed in the browser.
- data-role="header" is the toolbar created at the top of the page (usually used for a title or search button)
- data-role="main" defines the content of the page, such as text, images, forms, buttons, etc.
- The "ui-content" class is used to add inner and outer padding to the page.
- data-role="footer" is used to create the toolbar at the bottom of the page.
- In these containers you can add any HTML elements - paragraphs, images, headings, lists, etc.
![]() |
jQuery Mobile relies on HTML5 data-* attributes to support various UI elements, transitions, and page structures. Browsers that do not support them will silently discard them. |
|---|
Adding jQuery Mobile to a page
Using jQuery Mobile, you can create multiple different pages in a single HTML file.
You can use different href attributes to distinguish pages that use the same unique id:
Example
Try it »
Note: When a web application has a large amount of content (text, images, scripts, etc.) it will seriously affect the loading time. If you don't want to use internal page links you can use external files:
访问外部文件
Using a page as a dialog
A dialog is used to display page information or to input form information.
Adding data-rel="dialog" to a link makes a dialog pop up when the user clicks the link:
Example
Try it »