Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>jQuery mobile supports filtered lists Nativity, this should be fine for what you want to achieve.</p> <p><a href="http://jquerymobile.com/test/docs/lists/docs-lists.html#/test/docs/lists/lists-search.html" rel="nofollow">http://jquerymobile.com/test/docs/lists/docs-lists.html#/test/docs/lists/lists-search.html</a></p> <p>Edit:</p> <p>This demonstrates how to hide and show elements based on the contents of &lt; h2> from a search box. You may need to adapt it for your project but it should get you started.</p> <p><a href="http://jsfiddle.net/A3qFK/3/" rel="nofollow">http://jsfiddle.net/A3qFK/3/</a></p> <pre><code>&lt;script&gt; // This makes the contains selector case insensitive // Use :containsCaseInsensitive in place of :contains() jQuery.expr[':'].containsCaseInsensitive = function(a, i, m) { return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) &gt;= 0; }; // When a key is pressed, hide and show relevant list items $("#Search").live('keyup', function(e) { var SearchTerm = $(this).val(); // Find items to hide var ItemsToHide = $("li", "#ItemList").not(":containsCaseInsensitive("+ SearchTerm +")"); $(ItemsToHide).hide(); // Find items to show var ItemsToShow = $("h2:containsCaseInsensitive(" + SearchTerm + ")", "#ItemList").parent(); $(ItemsToShow).show(); }); &lt;/script&gt; &lt;input type="text" id="Search"&gt; &lt;ul id="ItemList" data-role="listview" data-filter="true"&gt; &lt;li&gt; &lt;h2&gt;Item 1&lt;/h2&gt; &lt;p&gt;Winner&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;h2&gt;Item 2&lt;/h2&gt; &lt;p&gt;description&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;h2&gt;Lorem&lt;/h2&gt; &lt;p&gt;Some more content&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;h2&gt;Ipsum&lt;/h2&gt; &lt;p&gt;Content&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload