How do I search for something in html css js?

1
So I would like to be able to search for items in html, without a bank, because the items will not be added dynamically, they will already be pre-established, as I am a beginner I have no idea how to do this, if someone can help me I thank you in advance.

ul{
list-style: none;
}
<input type="text" placeholder="Pesquise aqui">
<ul>
<li>Abacate</li>
<li>Banana</li>
<li>Cenoura</li>
<li>Tomate</li>
</ul>
    
asked by anonymous 01.07.2018 / 07:36

1 answer

1

There it is. The logic is simple: every time a key is pressed within input , the Javascript code generates a regular expression with the value of input , which expression is compared to the text of each list item. Items whose text does not correspond to it receive display: none; in their css, so they are hidden. Those that correspond, are with display: block;

Note: The script only works to find items that

01.07.2018 / 08:12