1
<div class="divBusca">
<input class="txtBusca" type="text" name="Tópicos"
id="txtBusca" placeholder="Buscar por item..."/>
<br><br><br>
</div>
<br>
<ul id="ulItens">
<li class="pushy-link"><a href=""> Agenda </a></li>
<li class="pushy-submenu">
<button> Relatórios </button>
<ul>
<li class="pushy-link"><a href=""> Relatório </a></li>
<li class="pushy-link"><a href=""> Relatório comparação </a></li>
<li class="pushy-link"><a href=""> Relatório de pedidos </a></li>
<li class="pushy-link"><a href=""> Relatório grafico pico vendas </a></li>
<li class="pushy-link"><a href=""> Relatório grafico pico por qtd </a></li>
</ul>
</li>
<li class="pushy-submenu">
<button> eCommerce </button>
<ul>
<li class="pushy-link"><a href=""> Todos Pedidos </a></li>
<li class="pushy-link"><a href=""> Total itens </a></li>
<li class="pushy-link"><a href=""> Importar</a></li>
<li class="pushy-link"><a href=""> Importar manual </a></li>
<li class="pushy-link"><a href=""> Faturamento </a></li>
</ul>
</li>
</ul>
I would like to search for "Report" and appear the "Report". It should be extremely simple but I am not knowing fit the code.
<script type="text/javascript">
$(function()
{
$("#txtBusca").keyup(function()
{
var texto = $(this).val().toLowerCase();
$("#ulItens li").css({"display":"block"}).addClass("pushy-submenu-open");
if($(this).text().toLowerCase().indexOf(texto) == 0)
{
$("#ulItens li").removeClass("pushy-submenu-open");
}
$("#ulItens li").each(function()
{
if($(this).text().toLowerCase().indexOf(texto) < 0)
{
$(this).css({"display":"none"});
}
});
});
});
</script>
If you remove the accent from all words in the list and then search for Report you can ;)
– MauroAlmeida
Related: https://answall.com/a/148229/3774
– Icaro Martins
For me it would not solve because the menu necessarily has to have the accentuation
– Lucas
Use regular expressions to remove accentuated and special characters from the two strings before comparing them (play the value for distinct variables in order not to remove their original content). - Good example: https://answall.com/a/3995/58027
– Leandro Paiva