I set a class name to div tag when I click on a button. I want to remove this class when i click outside. what should I do? I have tried some way, but it doesn't work, here is my try:
HTML
<div class="search-box"></div>
<input type="search" name="search" placeholder="search in here" id="search-input" autofocus="autofocus" style="display: none; ">
jQuery
$('.search-box').click(function() {
$('#search-input').toggle();
})
$("body").not('.search-box').click(function() {
$('#search-input').hide();
})