I have a function to search for elements in a table:
export const buscador = (este,columna) => {
var tableReg = $(este).parent("td").parent("tr").parent("thead").parent("table")[0];
var searchText =$(este).val().toLowerCase();
var cellsOfRow="";
var found=false;
var compareWith="";
for (var i = 1; i < tableReg.rows.length; i++)
{
cellsOfRow = tableReg.rows[i].getElementsByTagName('td');
found = false;
compareWith = cellsOfRow[columna].innerHTML.toLowerCase();
if(compareWith[0]!='<'){
if (searchText.length == 0 || (compareWith.indexOf(searchText) > -1))
{
found = true;
}
}
if(found)
{
tableReg.rows[i].style.display = '';
} else {
tableReg.rows[i].style.display = 'none';
}
}
}
which he called more or less like this in javascript-html:
<input placeholder="Buscar" onkeyup="buscador(this,0)" type="text" class="form-control" >
And as you will understand , this
it sent me to input
and from there to the search, but now I do something similar in react but it doesn't work for me:
<input placeholder="Buscar" onChange={()=>buscador(this,0)} type="text" className="form-control"/>
but in this case this
it is no longer input
what I expected, the truth is I don't know what is coming (I already saw it in the console I don't know what it would be.), but what I would like to achieve is to send the input in that variable. achievement?
The easiest way is to read the target of the event parameter that every event handler function receives: