search engine that is activated by clicking on the search icon

0

I have a search engine that is active when I click on the search icon and it is deactivated when I click on any part of the page , I want to deactivate that animation, that is, I want to leave the search engine fixed as any page without users having to click on the button to see the search engine, this is the function that it has but I can not deactivate it

function(c) {return a.call(b.src, b.listener, c)}
    
asked by Header90 29.07.2018 в 01:56
source

1 answer

0

You could use the .onkeyup event in your search input, and each time the event is executed, call your function Here is a small example of searching for names of a table using the event .onkeyup

document.getElementById("buscador").onkeyup = function() {functionBuscar()};
function functionBuscar() {
  var input, filter, table, tr, td, i;
  input = document.getElementById("buscador");
  filtro = input.value.toUpperCase();
  table = document.getElementById("myTable");
  tr = table.getElementsByTagName("tr");
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[0];
    if (td) {
      if (td.innerHTML.toUpperCase().indexOf(filtro) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }       
  }
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input type="text" id="buscador"  placeholder="Buscardor" title="Buscar nombres">

<table id="myTable" border="1">
  <tr>
    <th >Nombre</th>
    <th >Apellido</th>
  </tr>
  <tr>
    <td>Fernando</td>
    <td>Torrico</td>
  </tr>
  <tr>
    <td>Dilan</td>
    <td>Menese</td>
  </tr>
  <tr>
    <td>Otro nombre</td>
    <td>su apellido</td>
  </tr>
</table>

</body>
</html>
    
answered by 29.07.2018 в 02:27