jquery-mobile/docs/buttons/buttons-types.html

61 lines
2.5 KiB
HTML
Raw Normal View History

2010-10-11 18:25:08 +00:00
<!DOCTYPE html>
<html>
2010-11-02 01:46:29 +00:00
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile Docs - Button types</title>
<link rel="stylesheet" href="../../themes/default/" />
<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
2011-04-14 20:04:47 +00:00
<script src="../../js/jquery.js"></script>
<script src="../../js/"></script>
<script src="../docs/docs.js"></script>
2010-10-11 18:25:08 +00:00
</head>
<body>
<div data-role="page">
2010-10-11 18:25:08 +00:00
<div data-role="header" data-theme="b">
2010-10-11 18:25:08 +00:00
<h1>Button markup options</h1>
<a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
2010-10-11 18:25:08 +00:00
</div><!-- /header -->
<div data-role="content">
2010-10-15 21:34:00 +00:00
<p>Buttons that are used for navigation should be coded as anchor links, and those that submit forms as <code>button</code> elements &mdash; each will be styled identically by the framework.</p>
<h2>Styling links as buttons</h2>
<p>In the main content block of a page, you can style any anchor link as a button by adding the <code> data-role="button"</code> to the link. The framework will add all necessary classes to style the link as a button. For example, this markup: </p>
<code>
&lt;a href=&quot;index.html&quot; data-role=&quot;button&quot;&gt;Link button&lt;/a&gt;
</code>
2010-10-15 21:29:50 +00:00
<p>Produces this <strong>link-based</strong> button:</p>
<a href="index.html" data-role="button">Link button</a>
2010-10-11 18:31:33 +00:00
<h2>Form buttons</h2>
<p>For ease of styling, the framework automatically converts any <code>button</code> element or <code>input</code> with a <code>type</code> of <code>submit</code>, <code>reset</code>, <code>button</code>, or <code>image</code> into a custom styled link-based button &mdash; there is no need to add the <code> data-role="button"</code> attribute. </p>
2010-10-15 21:29:50 +00:00
<p>The original form-based button is hidden, but remains in the markup. When a click event fires on a link button, it triggers a click on the original form button.</p>
2010-10-15 21:31:29 +00:00
<p><strong>Button</strong> based button:</p>
2010-10-11 18:25:08 +00:00
<button>Button element</button>
2010-10-15 21:31:29 +00:00
<p><strong>Input type="button"</strong> based button:</p>
2010-10-11 18:25:08 +00:00
<input type="button" value="Input type=button" />
2010-10-15 21:31:29 +00:00
<p><strong>Input type="submit"</strong> based button:</p>
2010-10-11 18:25:08 +00:00
<input type="submit" value="Input type=submit" />
2010-10-15 21:31:29 +00:00
<p><strong>Input type="reset"</strong> based button:</p>
2010-10-11 18:25:08 +00:00
<input type="reset" value="Input type=reset" />
2010-10-15 21:31:29 +00:00
<p><strong>Input type="image"</strong> based button:</p>
2010-10-11 18:25:08 +00:00
<input type="image" value="Input type=image" />
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>