michaelmcgurk michaelmcgurk - 1 year ago 84
HTML Question

Case-sensitive Live Search on a Table with jQuery

I have a Live Search on a Table using jQuery. It works really well but is not case sensitive so

will not show the same as

Demo: http://jsfiddle.net/qxks62x9/

$("#search").on("keyup", function() {
var value = $(this).val();

$("table tr").each(function(index) {
if (index !== 0) {

$row = $(this);

var id = $.map($row.find('td'), function(element) {
return $(element).text()
}).join(' ');

if (id.indexOf(value) <0) {
else {

table, tr, td, th{
border: 1px solid blue;
padding: 2px;

table th{
background-color: #999999;

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<br />
<input type="text" id="search" placeholder=" live search"></input>

Answer Source

You can just lowercase both strings.

Fiddle: https://jsfiddle.net/maq2xmrv/

  • (id.toLowerCase().indexOf(value.toLowerCase()) < 0)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download