11

I am making a search input on focus it shows a div with options with following:

$("#search").focus(function(){

$("#options").fadeIn("fast");

});

I am hiding the div back with this function

 $("#search").blur(function(){

$("#options").fadeOut("fast");

});

now the problem is even when user clicks at any checkbox in #option it hides. How I can stop it hidding when clicking checkboxes?

thecodeparadox
  • 86,271
  • 21
  • 138
  • 164
danny
  • 465
  • 3
  • 8
  • 18

1 Answers1

3
 $("#search").blur(function(e){
   e.stopPropagation()
   $("#options").fadeOut("fast");
});
Ram
  • 143,282
  • 16
  • 168
  • 197
  • $(this).children('input[type=checkbox]').on('click', function(){e.stopPropagation();}); // isn't this missing in the blur listener? – mtizziani Aug 22 '16 at 21:25