Created
July 13, 2011 21:26
-
-
Save metalim/1081372 to your computer and use it in GitHub Desktop.
jquery simplicity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
function update_filter($elements, str) { | |
var s = str.toLowerCase(); | |
$elements.each(function(){ | |
$(this).text().toLowerCase().indexOf(s) != -1 ? $(this).show() : $(this).hide(); | |
}); | |
} | |
</script> | |
Filter: <input onKeyUp="update_filter($('#my_table tbody tr'), this.value);"> | |
<table id="my_table"> | |
<thead> | |
<tr><th>Col 1</th><th>Col 2</th><th>Col 3</th></tr> | |
</thead> | |
<tbody> | |
<tr><td>Hello</td><td>World</td><td>$1234</td></tr> | |
<tr><td>Foo</td><td>Bar</td><td>$567</td></tr> | |
<tr><td>World</td><td>Domination</td><td>$890</td></tr> | |
<tr><td>1234</td><td>567</td><td>$1.99</td></tr> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment