1
$(document).ready(function () {
$('#textFind').click(function () {
$('.pesquisas').toggle(200);
});
});
$(function () {
$.expr[":"].contains = $.expr.createPseudo(function (a) {
return function (e) {
return ~$(e).text().toUpperCase().indexOf(a.toUpperCase());
}
});
$("[name=q]").on("input", function () {
$(".opcao").hide();
$(".opcao:contains('" + this.value + "')").show();
});
});
.pesquisas {
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="search" name="q" class="search-text" placeholder="Procurar..." autocomplete="off" id="textFind">
<div class="pesquisas" id="pesquisas">
<div class="opcao">
<a>Agenda</a>
</div>
<div class="opcao">
<a>Lista de clientes</a>
</div>
<div class="opcao">
<a>Cadastrar novo cliente</a>
</div>
<div class="opcao">
<a>Lista de fornecedores</a>
</div>
<div class="opcao">
<a>Cadastrar novo fornecedor</a>
</div>
<div class="opcao">
<a>Lista de produtos</a>
</div>
<div class="opcao">
<a>Cadastrar novo produto</a>
</div>
</div>
In the code above, by clicking on input research my div 'search' appears, as I do for it to appear only after typing more than one letter in input? For example, instead of when I click already appear the list, it should only appear, when I type the letters 'ag', the div containing agenda? And more, how do I so when I click off the div pesquisas she doesn’t show up anymore (display: none), and not just when I click the input again?
OBS. The intention of each button <a>...</a> is that they are clickable. Subsequently they will have href='algum lugar'.
I just switched to
$('.pesquisas').show('slide');for every two characters typeddivhide.– Rafael
As the intention of the buttons
<a>...</a>are be clickable by clicking on some option to divpesquisaswill disappear and will not forward to the defined page using the function$('#textFind').focusout(function().– Rafael
@Rafael I made the change to get the click off the div
– JrD