Search text with given input.

by Clear

HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input placeholder="Search Me" id="box" type="text" /> 
<br />
<table class="navtitle">
    <tbody><tr><td>
        apples
    </td></tr></tbody>
</table>
<table class="navtitle"><tbody><tr><td>
apricots
</td></tr></tbody></table>
<table class="navtitle"><tbody><tr><td>
acai
</td></tr></tbody></table>
<table class="navtitle"><tbody><tr><td>
blueberry
</td>
<td align="right">
    <a href="index.php?do=buildnavprefs&amp;nojs=0&amp;prefs=finder_0&amp;dowhat=expand&amp;id=vbulletin_0#grpvbulletin_0" target="_self" onclick="toggle_group('vbulletin_0'); return false;" oncontextmenu="toggle_group('vbulletin_0'); save_group_prefs('vbulletin_0'); return false"><img src="../cpstyles/vb5style/cp_expand.gif" title="Expand Group" id="button_vbulletin_0" alt="+" border="0" /></a>
			</td>
</tr></tbody></table>
<table class="navtitle"><tbody><tr><td>
bananas
</td></tr></tbody></table>
<table class="navtitle"><tbody><tr><td>
cherry
</td></tr></tbody></table>
<table class="navtitle"><tbody><tr><td>
coconut
</td></tr></tbody></table>

JavaScript

$('#box').keyup(function(){
    alert('test');
   var valThis = $(this).val().toLowerCase();
    $('.navtitle').each(function(){
     var text = $(this).text().toLowerCase();
        (text.indexOf(valThis) != -1) ? $(this).show() : $(this).hide();            
   });
});