Home › Forums › JavaScript › On body click, hide search › Re: On body click, hide search
April 21, 2013 at 7:16 am
#132573
chrisburton
Participant
@CrocoDillon I haven’t tested your code yet so while I do, what about this:
$(‘.find’).click(function(event) {
event.preventDefault();
$(‘.search’).slideDown(‘slow’);
});
$(‘.find, .search’).click(function(e) {
e.stopPropagation();
});
$(document).click(function() {
$(‘.search’).slideUp(‘slow’);
});
It seems to work perfectly. Below is a test on CodePen.
Update: Thanks for the help guys. My solution seems to have the exact functionality I’m looking for. Although, it is a bit bulky but I can deal with that.