Capturing all the click event

前端 未结 10 1576
无人共我
无人共我 2020-12-14 08:46

I am thinking of to add a javascript function to capture all the click events inside a html page.

So I am adding a global function that govern

10条回答
  •  余生分开走
    2020-12-14 09:24

    ​window.onclick = function (e) {
        if (e.target.localName == 'a') {
            console.log('a tag clicked!');
        }
    }​
    

    The working demo.

提交回复
热议问题