How to hide searchform with blur event?
-
Hello, guys. I am new to wordpress development. I need to hide the search input clicking outside, but i cant achieve that by any means. Dont know what am doing wrong. Here is the code i am using:
document.getElementById('fa-button').addEventListener('click', hide = function(){ document.getElementById('search_area_visible').style.visibility = 'hidden'; document.getElementById('search_area_hidden').style.visibility = 'visible'; }, false); document.getElementById('fechar-div').addEventListener('click', hide = function(){ document.getElementById('search_area_hidden').style.visibility = 'hidden'; document.getElementById('search_area_visible').style.visibility = 'visible'; }, false);
I have used a X to close the div, but i would like to close by clicking outside the div. Here is part of the html:
<span><i id="fa-button" class="fas fa-search"></i></span> <div id="search_area_hidden" class="col-sm-2 d-flex justify-content-end search-area"> <?php get_search_form(); ?><span id="fechar-div">X</span> </div> </div>
Thanks in advance.
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.