Search with JQuery does not work in Firefox

0

I created a code to fetch information from a table and the code just does not work in Firefox

The error that appears in firefox is:

  

Error: Syntax error, unrecognized expression: unsupported pseudo:   contains-ci jquery.min.js: 2: 12733

My code:

$(document).ready(function() {
  //Começa a digitar
  $("#buscar").keyup(function() {
    //pega o css da tabela 
    var tabela = $(this).attr('alt');
    if ($(this).val() != "") {
      $("." + tabela + " tbody>tr").hide();
      $("." + tabela + " td:contains-ci('" + $(this).val() + "')").parent("tr").show();
    } else {
      $("." + tabela + " tbody>tr").show();
    }
  });
  $.extend($.expr[":"], {
    "contains-ci": function(elem, i, match, array) {
      return (elem.textContent || elem.innerText || $(elem).text() || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><tableclass="table tabela" id="tabela">
  <thead>
    <tr>
      <th>Veículo#</th>
      <th>Placa</th>
      <th>Tipo</th>
      <th>Controle</th>
      <th>Terminal</th>
      <th>Rota</th>
      <th>Último Odômetro</th>
      <th>Leitura</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Porsche</td>
      <td>BUD-0001</td>
      <td>100</td>
      <td>K</td>
      <td>0</td>
      <td>0</td>
      <td>18/04/2017</td>
      <td>1100</td>
    </tr>
    <tr>
      <td>Ferrari</td>
      <td>BUD-0002</td>
      <td>100</td>
      <td>K</td>
      <td>0</td>
      <td>0</td>
      <td>19/04/2017</td>
      <td>200</td>
    </tr>
  </tbody>
</table>
<input id="buscar" alt="tabela" type="text" class="form-control" placeholder="Buscar...">

I've already broken my mind with this. Does anyone know what can be done?

    
asked by anonymous 04.05.2017 / 15:12

1 answer

0

I decided to search differently and solved the problem:

$(document).on('keyup', '#iPesquisa', function(){
    $("#tabela tr").hide();
    $("#tabela td:contains("+$(this).val().toUpperCase()+")").parent().show();
});
// Função para transformar contains em Maiuscula
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
    return function(elem){
        return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
    };
});
    
12.06.2017 / 22:55