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

#132568
chrisburton
Participant

I ended up getting it working but can any Javascript professionals check out my code?

$(‘.find’).click(function(event) {
event.preventDefault();
$(‘.search’).slideDown(‘slow’);
});

$(‘.find’).click(function(e) {
e.stopPropagation();
});

$(document).click(function() {
$(‘.search’).slideUp(‘slow’);
});

CodePen

Update: Damn. I just noticed that if I go to click in the input, it hides the search bar. This is tricky.