5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>jQuery Mobile Docs - Search input</title>
7 <link rel="stylesheet" href="../../../css/themes/default/" />
8 <link rel="stylesheet" href="../../_assets/css/jqm-docs.css"/>
9 <script src="../../../js/jquery.js"></script>
10 <script src="../../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
11 <script src="../../_assets/js/jqm-docs.js"></script>
12 <script src="../../../js/"></script>
16 <div data-role="page" class="type-interior">
18 <div data-role="header" data-theme="f">
20 <a href="../../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
21 </div><!-- /header -->
23 <div data-role="content">
24 <div class="content-primary">
26 <form action="#" method="get">
30 <ul data-role="controlgroup" data-type="horizontal" class="localnav">
31 <li><a href="index.html" data-role="button" data-transition="fade" class="ui-btn-active">Basics</a></li>
32 <li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
33 <li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
34 <li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
37 <p>Search inputs are a new HTML type that is styled with pill-shaped corners and adds a "x" icon to clear the field once you start typing. Start with an <code>input</code> with a <code>type="search"</code> attribute in your markup. View the <a href="../../api/data-attributes.html">data- attribute reference</a> to see all the possible attributes you can add to search inputs.</p>
39 <p>Set the <code>for</code> attribute of the <code>label</code> to match the ID of the <code>input</code> so they are semantically associated. It's possible to <a href="../docs-forms.html">accessibly hide the label</a> if it's not desired in the page layout, but we require that it is present in the markup for semantic and accessibility reasons.</p>
42 <label for="search-basic">Search Input:</label>
43 <input type="search" name="search" id="searc-basic" value="" />
46 <p>This will produce a basic search input. The default styles set the width of the input to 100% of the parent container and stacks the label on a separate line.</p>
47 <label for="search-basic">Search Input:</label>
48 <input type="search" name="search" id="search-basic" value="" />
51 <p>Optionally wrap the search input in a container with the <code>data-role="fieldcontain"</code> attribute to help visually group it in a longer form.</p>
54 <strong><div data-role="fieldcontain">
55 </strong> <label for="search">Search Input:</label>
56 <input type="search" name="password" id="search" value="" />
58 </strong></code></pre>
60 <p>The search input is now displayed like this:</p>
61 <div data-role="fieldcontain">
62 <label for="search">Search Input:</label>
63 <input type="search" name="search2" id="search" value="" />
66 <p>Themed variation:</p>
67 <div data-role="fieldcontain">
68 <label for="searchA">Search Input:</label>
69 <input type="search" name="search3" id="searchA" value="" data-theme="a" />
74 <h2>Calling the textinput plugin</h2>
76 <p>This plugin will auto initialize on any page that contains a text input with the <code>type="search"</code> attribute, no need for a <code>data-role</code> attribute in the markup. However, if needed you can directly call the <code>textinput</code> plugin on a selector, just like any jQuery plugin:</p>
78 $('.mySearchInput').textinput();
84 </div><!--/content-primary -->
86 <div class="content-secondary">
88 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
90 <h3>More in this section</h3>
92 <ul data-role="listview" data-theme="c" data-dividertheme="d">
94 <li data-role="list-divider">Form elements</li>
95 <li><a href="../docs-forms.html">Form basics</a></li>
96 <li><a href="../forms-all.html">Form element gallery</a></li>
97 <li><a href="../textinputs/index.html">Text inputs</a></li>
98 <li data-theme="a"><a href="index.html">Search input</a></li>
99 <li><a href="../slider/">Slider</a></li>
100 <li><a href="../switch/">Flip toggle switch</a></li>
101 <li><a href="../radiobuttons/">Radio buttons</a></li>
102 <li><a href="../checkboxes/">Checkboxes</a></li>
103 <li><a href="../selects/">Select menus</a></li>
104 <li><a href="../forms-themes.html">Theming forms</a></li>
105 <li><a href="../forms-all-native.html">Native form elements</a></li>
106 <li><a href="../forms-sample.html">Submitting forms</a></li>
113 </div><!-- /content -->
115 <div data-role="footer" class="footer-docs" data-theme="c">
116 <p>© 2011 The jQuery Project</p>