# jQuery Mobile Filters

« Previous
Next Chapter »

## Filterable Elements

All elements that have more than one child element, can be filtered.

How To Create a Search Field:

- The element you want to be filterable, must include the data-filter="true" attribute.
- Create an <input> element with a specified id and add the data-type="search" attribute. This will create a basic search field. Wrap the <input> in a form, and add the "ui-filterable" class to the <form> element - this will adjust the margin between the search field and the filterable element.
- Then, add the data-input attribute to the filterable element. Its value must match the id of the <input> element.

Below, we have created a filterable list view:

## Search for elements in a list

<form class="ui-filterable">
<input id="myFilter" data-type="search">
</form>
<ul data-role="listview" data-filter="true" data-input="#myFilter">
<li><a href="#">Adele</a></li>
<li><a href="#">Billy</a></li>
<li><a href="#">Calvin</a></li>
</ul>
Try it yourself »

Tip: Use a placeholder to specify a short hint that describes the expected value of the search field:

## Example

<input id="myFilter" data-type="search" placeholder="Search for names..">
Try it yourself »

## Custom Filter

The text inside each child element is the actual text that is used for filtering (like "Adele" or "B" for "Billy"). However, if you want to filter the search to a custom filter text instead, you can add the data-filtertext attribute to any child element:

## Example

<li data-filtertext="fav"><a href="#">Adele</a></li>
Try it yourself »

| If you use the data-filtertext attribute on an element, the original text/content of that particular element is ignored for filtering (In the example above, you are no longer able to search for the list item "Adele". You can only find Adele by typing the keywords "f, a, v or fav".)

## More Examples

Filter Collapsible Lists
How to filter a collapsible set of lists.

Filter Tables
How to filter a table.

Filter <div> elements
How to filter a <div> element containing child <p> elements.

« Previous
Next Chapter »

### WEB HOSTING

UK Reseller Hosting

### WEB BUILDING

FREE Website BUILDER Free HTML5 Templates

### W3SCHOOLS EXAMS

HTML, CSS, JavaScript, PHP, jQuery, XML, and ASP Certifications

### SHARE THIS PAGE

### Color Picker

### HTML/CSS

HTML Tutorial HTML5 Tutorial CSS Tutorial CSS3 Tutorial Bootstrap Tutorial

### JavaScript

JavaScript Tutorial jQuery Tutorial jQuery Mobile Tutorial AngularJS Tutorial AJAX Tutorial JSON Tutorial

### Graphics

Canvas Tutorial SVG Tutorial Google Maps Tutorial

### Server Side

SQL Tutorial PHP Tutorial ASP Tutorial ASP.NET Tutorial VBScript Tutorial AppML Tutorial

### Web

Web Building Web Statistics Web Certification

### XML

XML Tutorial DTD Tutorial Schema Tutorial XML DOM Tutorial XPath Tutorial XSLT Tutorial XQuery Tutorial XSL-FO Tutorial RSS Tutorial WSDL Tutorial

### HTML/CSS

HTML Tag Reference HTML Event Reference HTML Color Reference CSS 1,2,3 Reference Bootstrap Reference

### JavaScript

JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference Google Maps Reference

### Server Side

PHP Reference SQL Reference ASP Reference VBScript Reference Razor Reference ASP.NET Reference

### XML

XML DOM Reference XSLT Reference XSL-FO Reference XPath Reference XQuery Reference Schema Reference RSS Reference SVG Reference

### HTML Charsets

HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8

### HTML/CSS

HTML Examples CSS Examples

### Browser Scripting

JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples

### Server Scripting

PHP Examples ASP Examples VBScript Examples Razor Examples .NET Examples

### XML Languages

XML Examples DTD Examples XML DOM Examples XSL Examples XSLT Examples XPath Examples XQuery Examples Schema Examples RSS Examples SVG Examples