I have a floating div that gets displayed, and I want it to be hidden when the user clicks off the div. This would be similar to the .hover() function callback when hoverin
Using an event handler on the document works well for me:
function popUp( element ) { element.onmousedown = function (event) { event.stopPropagation(); }; document.onmousedown = function () { popDown( element ); }; document.body.appendChild( element ); } function popDown( element ) { document.body.removeChild( element ); document.onmousedown = null; }