Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript On body click, hide search Re: On body click, hide search

#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.

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.