auto-complete search suggestion drop-down popup
Im trying to make a popup div (when a text-box value changes) and it can be closed (visibility: none) by clicking anywhere outside the div. Similar to Google suggestion drop-down. How can I know weather the mouse click has happened inside the div or outside. I need to implement this using javascript and jsp. Please help. The jquery solution would be $("body > div").click(function() { if ($(this).attr("id") == "div-id") { // inside the DIV } else { // not inside the DIV } }); or $("html").click(function (e) { if (e.target == document.getElementById("div-id")) alert("Inside DIV"); else alert(