Latest web development tutorials

jQuery Mobile Filter

You can filter element

All the elements if one or more sub-elements can be filtered.

How to create a search field:

  • You want to filter element must use the data-filter = "true" attribute.
  • Create <input> element and specify the id, plus data-type on the element = "search" attribute. This will create a basic search field. The <input> element is placed in a form, the form <form> element uses "ui-filterable" class - This class will be adjusted outside the search field and away from the filter element.
  • Then add the data-input attribute for the filter element. This value needs to be id <input> elements.

Next we create a filtered list:

List search elements

<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"

Tip: You can use the placeholder attribute in the search field to set the message:

Examples

<input id = "myFilter" data -type = "search" placeholder = " according to search for the name ..">

try it"

Custom filters

Generally inserted into the text of each list item is to use as a filter text (such as A corresponding to "Adele" or "B" corresponds to "Billy"). But if you want to specify a custom text filter, you need to use data-filtertext attribute in child elements:

Examples

<li data-filtertext = "fav "> <a href="#"> Adele </a> </ li>

try it"
Note If you use a data-filtertext attribute in the element, the source text content elements will be ignored when the filter, then if you have to look for the list of items "Adele", requires the use of keywords as: f, a, v, or fav.
Examples

More examples

Filtration folded List
How folded filter list.

Filter the table
How to filter table content.

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