Javascript Detect click event outside of div

前端 未结 10 947
孤城傲影
孤城傲影 2020-11-27 06:07

I have a div with id=\"content-area\", when a user clicks outside of this div, I would like to alert them to the fact that they clicked outside of it. How would I use JavaSc

10条回答
  •  清酒与你
    2020-11-27 06:36

    Use document.activeElement to see which of your html elements is active.

    Here is a reference: document.activeElement in MDN

提交回复
热议问题