Highlight

2012-06-21

Filtering a table using jQuery:

$(document).ready(function(){
 $.extend($.expr[':'], {
  'containsi': function(elem, i, match, array){
   return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0
  }
 })
})
function CT_filterTable(table_id, column_nr, text) {
 table_id = "#"+table_id
 $(table_id+" tr").hide();
 $(table_id+" tr>td:nth-child("+column_nr+"):containsi('"+text.replace("'", "\\'")+"')").parent().show()
}

1 comment: