I have a filter of results but I need that when writing in the search box the titles disappear; just like what the code does next:
$(document).ready(function () {
(function ($) {
$('#buscar').keyup(function () {
var rex = new RegExp($(this).val(), 'i');
$('#aBuscar p').hide();
$('#aBuscar p').filter(function () {
return rex.test($(this).text());
}).show();
})
}(jQuery));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="buscar" placeholder="Buscar">
<div id="aBuscar">
<h1>Titulo0</h1>
<p>buscar</p>
<p>encontrar</p>
<h1>Titulo1</h1>
<p>correr</p>
<p>detenerse</p>
</div>
The function uses it from the response of another user but it only needs to hide the titles when starting to write in the search box and then show them when all the contents of the search box are deleted.
Thanking you in advance for your help.