How to blur the div element?

Aamir Afridi picture Aamir Afridi · Aug 11, 2009 · Viewed 61.8k times · Source

I have a dropdown menu inside a DIV.

I want the dropdown to be hide when user click anywhere else.

$('div').blur(function() { $(this).hide(); }

is not working.

I know .blur works only with <a> but in this case what is the simplest solution?

Answer

comenk picture comenk · Jul 28, 2011

Try using tabindex attribute on your div, see:

Check this post for more information and demo.