I'm trying to remove rows from the table where, in the Employee column, the name does not contain the string "o", as I did in the code below. The problem is that even returning false for comparison if "o" is contained in "Joseph", the line is not deleted.
HTML:
<!DOCTYPEhtml><html><head><metacharset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script></head><body><table><thead><tr><th>Código</th><th>Funcionário</th><th>Cargo</th></tr></thead><tbody><tr><td>1</td><td>João</td><td>AnalistadeSistemas</td></tr><tr><td>2</td><td>Maria</td><td>Advogada</td></tr><tr><td>3</td><td>José</td><td>EngenheiroCivil</td></tr><tr><td>4</td><td>Joãozinho</td><td>Desenvolvedor</td></tr></tbody></table></body></html>
JS:
(function(){$(document).ready(function(){$('tabletd:nth-child(2)').each(function(indice){vartxtDigitado="Oã";
var pattern = new RegExp(txtDigitado, 'i');
var item_celula = $(this).text();
if(pattern.test(item_celula)) {
$('table tbody tr').eq(indice+1).remove();
}
});
});
})();