How to blur ` detection @Juhana – l2aelba Feb 14 '13 at 12:51

  • maybe I have to make my own custom select box :( – l2aelba Feb 14 '13 at 12:54
  • Why we can't do like `$("*:not(select)").click(function(){$("select").blur();});` ? – l2aelba Feb 14 '13 at 12:58
  • @l2aelba Might be worth taking a look at this question: http://stackoverflow.com/questions/1403615/use-jquery-to-hide-a-div-when-the-user-clicks-outside-of-it Not exactly the same, but the basic principle (detecting clicks outside of an element) is going to be the same. – Anthony Grist Feb 14 '13 at 13:01
  • Based on this and your previous questions, yes, it would probably be worth it to use a custom select field because you're really trying to twist the default into doing things it just won't do. – JJJ Feb 14 '13 at 14:24
  • 1 Answers1

    2

    The problem is that the first click only closes the select element, it doesn't unfocus it. So to solve you problem, you should catch the close event and then do:

    $("select").blur(); // This will even call your event listener!
    

    But how to catch the close event? Unfortunately, there is no such (official) event. But perhaps this question helps: Is there a DOM event that fires when an HTML select element is closed?

    Community
    • 1
    • 1
    11684
    • 7,356
    • 12
    • 48
    • 71