How can a filter script be optimized to a table?

0

I have the following function in JavaScript to filter data from a table, but its response time while I am writing the data to search is very slow, is there any way to optimize it?

    
asked by Claudio Navarrete 01.08.2018 в 21:34
source

1 answer

1

Brother, jQuery already has the option to filter data and is very easy to use.

As simple as adding

$(document).ready(function(){
  $("#buscar").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#tablaCotizaciones1 tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});

Note that I add the function in the "keyup" to the text $ ("# search"), that is to say that it searches in "real time" so to speak it

    
answered by 01.08.2018 / 21:49
source