JSFiddle - React, Tailwind, and code Playground
HTML
<div id="faq">
<p><label>Search</label><br />
<input id="search" value="" size="30" /></p>
<p> </p>
<ul id="result">
<li><strong>How round is the Earth?</strong><br /><br /><em>
Very round.
<br /><br /></em></li>
<li><strong>How rectangular is paper?</strong><br /><br /><em>
Very rectangular.
<br /><br /></em></li>
</ul>
</div><!-- #faq -->
CSS
#faq EM {
display:none;
}
#faq LI STRONG {
font-weight:normal;
color:#246;
text-decoration:underline;
cursor:pointer;
}
JavaScript
$('LI STRONG').click(function(e) {
e.preventDefault(); // disable text selection
$('EM', $(this).parent()).slideToggle();
return false; // disable text selection
});
$('#search').keyup(function(e) {
var s = $(this).val().trim();
// show all results
$('#result LI').show();
// split the search into words
var keywords = s.split(' ');
// loop over the keywords and if it's not in a LI, hide it
for(var i=0; i<keywords.length; i++) {
$('#result LI:not(:contains('+keywords[i]+'))').hide();
}
});