JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="search" placeholder="Search" />
<div id="listing">
<div class="result">
<h3>Listing title 1</h3>
<p>This is some text that you can use to filter.</p>
</div>
<div class="result">
<h3>Listing title 1</h3>
<p>Other Text</p>
</div>
<div class="result">
<h3>Listing title 1</h3>
<p>More text to filter</p>
</div>
<div class="result">
<h3>Listing title 1</h3>
<p>Some more and more</p>
</div>
<div class="result">
<h3>Listing title 1</h3>
<p>Testing testing</p>
</div>
</div>
JavaScript
var search_results = function() {
$("#search").keyup(function() {
var filter = $(this).val();
if (filter.length > 0) {
$("#listing .result").each(function() {
if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).hide();
} else {
$(this).show();
}
});
} else {
$("#listing .result").show();
}
});
};
search_results();