i have listener runs when click on document.
document.addeventlistener('click', print); function print(element) { dosomething(); }
it creates div id=panel, print information.
when run print function detect whether clicked outside of div#panel (the panel exists when click second time).
i wish not use mouseout event listener because think redundant use listener mouse movements when event click fired.
how detect when clicked out of div#panel?
you can check target
of jquery's click
event, element was:
$(document).click(function(e) { var target = $(e.target); if( !target.is("#panel") && target.closest("#panel").length === 0 ) { // click not on or inside #panel } });
Comments
Post a Comment