I want to hide a div by pressing a submit button which will add to the client a cookie. I have tried many ways but till the moment I haven't figured out how can I do it. Here is my JavaScript & HTML to try. HTML code + CSS:
<div class="postulacion" id="formulario">
<span class="s_no foca">¿Estás interesado?</span>
<span class="s_n"> ¡Rellene el siguiente formulario!</span>
<div class="formulario">
<span class="recuerde"> <i class="fas fa-lock"></i> Recuerde que toda su información se encuentra encriptada. </span>
CSS Code:
.formulario.hidden{
display: none !important;
}
JavaScript code:
$.cookie('_dro', 'the_value');
// Create expiring cookie, 7 days from then:
$.cookie('_dro', 'the_value', { expires: 7 });
// Read a cookie
$.cookie('_dro'); // => 'the_value'
$.cookie('not_existing'); // => null
$("#form_send").click(
$.cookie('_dro', 'the_value', { expires: 7 }));
if (document.cookie.indexOf('_dro') > -1) {
$('.formulario').addClass('hidden');
}
else {
$('.formulario').removeClass('hidden');
}