How to stop event propagation with inline onclick attribute?

前端 未结 13 2091
情书的邮戳
情书的邮戳 2020-11-21 23:46

Consider the following:

13条回答
  •  天涯浪人
    2020-11-22 00:31

    I cannot comment because of Karma so I write this as whole answer: According to the answer of Gareth (var e = arguments[0] || window.event; [...]) I used this oneliner inline on the onclick for a fast hack:

    ..

    I know it's late but I wanted to let you know that this works in one line. The braces return an event which has the stopPropagation-function attached in both cases, so I tried to encapsulate them in braces like in an if and....it works. :)

提交回复
热议问题