How do I handle a click anywhere in the page, even when a certain element stops the propagation?

后端 未结 8 1813
臣服心动
臣服心动 2020-12-04 23:51

We are working on a JavaScript tool that has older code in it, so we cannot re-write the whole tool.

Now, a menu was added position fixed to the bottom and the clien

8条回答
  •  生来不讨喜
    2020-12-05 00:37

    document.body.addEventListener("keyup", function(event) {
      if (event.keyCode === 13) {
      event.preventDefault();
      console.log('clicked ;)');
    }
    });
    

    DEMO

    https://jsfiddle.net/muratkezli/51rnc9ug/6/

提交回复
热议问题