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
  • 84,459
  • 21
  • 136
  • 161
danny
  • 455
  • 2
  • 8
  • 18

1 Answers1

3
 $("#search").blur(function(e){
   e.stopPropagation()
   $("#options").fadeOut("fast");
});
Ram
  • 140,563
  • 16
  • 160
  • 190
  • $(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