This method is good until there is some “focusable” elemt inside your div(like input). In this situation when u click on this input – it takes focus and “div” blur is called despite the fact “clisk is inside div”
You can solve this problem by doing something not very good like
divElement.find('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]').add(divElement).each(function() {
$(this).blur(function () {
closeDivTimeoutId = setTimeout(function () {
//Your blur code here
}, 100);
}).focus(function () {
if (closeDivTimeoutId ) {
clearTimeout(closeDivTimeoutId );
}
});
});