jQuery Mobile - Table Filter


To generate a table filter, set data-filter attribute to true on the element of the table to produce a filter for rows.


Following example demonstrates the use of table filter in jQuery Mobile.

<!DOCTYPE html>
      <title>Filterable Table</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

         <input id = "filterTable-input" data-type = "search">
      <table data-role = "table" id = "movie-table" data-filter = "true" 
         data-input = "#filterTable-input" class = "ui-responsive">
               <th data-priority = "1">Rank</th>
               <th data-priority = "persist">Country</th>
               <th data-priority = "2">Area sq.km.</th>
               <th data-priority = "3">Capital</th>
               <th data-priority = "4">Currency</th>
               <td>Russian ruble</td>
               <td>Canadian dollar</td>
               <td>United States of America</td>
               <td>Washington, D.C.</td>
               <td>US Dollar</td>
               <td>Brazilian real</td>
               <td>Australian dollar</td>
               <td>New Delhi</td>
               <td>Indian Rupee</td>


Let's carry out the following steps to see how the above code works −

  • Save the above html code as filterable_table.html file in your server root folder.

  • Open this HTML file as http://localhost/filterable_table.html and the following output will be displayed.

Kickstart Your Career

Get certified by completing the course

Get Started