jQuery Mobile List View

jQuery Mobile List View

List views in jQuery Mobile are standard HTML lists: ordered lists (<ol>) and unordered lists (<ul>).

To create a list, add the data-role="listview" attribute to the <ol> or <ul> elements. To make these items clickable, specify a link in each list item (<li>):

Example

<ol data-role="listview">
  <li><a href="#">List Item</a></li>
</ol>
<ul data-role="listview">
  <li><a href="#">List Item</a></li>
</ul>

Try It Yourself

To add rounded corners and margins to the list, use the data-inset="true" attribute:

Example

<ul data-role="listview" data-inset="true">

Try It Yourself

Tip:By default, list items in the list are automatically converted to buttons (no need for data-role="button").

List Dividers

List dividers (List Dividers) are used to organize and group items into categories/sections.

To specify list dividers, add the data-role="list-divider" attribute to the <li> element:

Example

<ul data-role="listview">
 <li data-role="list-divider">Europe</li>
  <li><a href="#">France</a></li>
  <li><a href="#">Germany</a></li>
</ul>

Try It Yourself

If your list is in alphabetical order (such as a contact list), jQuery Mobile automatically adds appropriate dividers by setting the data-autodividers="true" attribute on the <ol> or <ul> elements:

Example

<ul data-role="listview" data-autodividers="true">
  <li><a href="#">Adam</a></li>
  <li><a href="#">Angela</a></li>
  <li><a href="#">Bill</a></li>
  <li><a href="#">Calvin</a></li>
  ...
</ul>

Try It Yourself

Tip:The data-autodividers="true" attribute creates dividers by capitalizing the first letter of the list item text.

Search Filter

To add a search box to the list, use the data-filter="true" attribute:

Example

<ul data-role="listview" data-filter="true"</ul>

Try It Yourself

By default, the text in the search box is "Filter items...".

To modify the default text, please use the data-filter-placeholder attribute:

Example

<ul data-role="listview" data-filter="true" data-filter-placeholder="Search Name">

Try It Yourself

More Examples

Read-only List
How to create a list without links (not buttons, not clickable).