jQuery Mobile Buttons
Mobile applications are built on the simple clickable things you want to display.
Creating buttons in jQuery Mobile
In jQuery Mobile, buttons can be created in three ways:
- Use
- Use Element
- Use a with data-role="button" Element
Try it »
Try it »
Try it »
![]() |
In jQuery Mobile, buttons are automatically styled to make them more attractive and usable on mobile devices.We recommend using a with data-role="button" element to link between pages, and a or |
|---|
Navigation buttons
To link between pages with a button, use a with a data-role="button" attribute element:
Example
<
a href="#pagetwo" data-role="button"
Try it »
Inline buttons
By default, buttons fill the entire screen width. If you want a button that is only as wide as its content, or if you want to display two or more buttons side by side, add data-inline="true":
Example
![]() |
By default, grouped buttons are grouped vertically with no margins or space between them. Only the first and last buttons have rounded corners to create a nice appearance when grouped together. |
|---|
Back button
To create a back button, use the data-rel="back" attribute (which ignores the anchor's href value):
Example
data-rel="back" Return Try it »
More link button examples
| class | Description | Example |
|---|---|---|
| ui-btn-b | Change the button color to black and the font to white (the default is a gray background with black font). | Try it |
| ui-corner-all | Add rounded corners to buttons | Try it |
| ui-mini | Make small buttons | Try it |
| ui-shadow | Add shadows to buttons | Try it |
|
| If you need to use more styles, separate each style class with a space, e.g.: class="ui-btn ui-btn-inline ui-btn-corner-all ui-shadow"
默认情况下 按钮有圆角及阴影效果。 和
| --- | --- |
For a more complete list of CSS classes, see our jQuery Mobile CSS Classes Reference Manual。
The next chapter demonstrates how to add icons to buttons.