开发者

calling e.stopImmediatePropagation() from onclick attribute

How do I get the event object from an onclick attribute?

I have tried:

<a href="something.html" onclick="function(e){e.stopImmediatePropagation();}">Click me</a>

Also, I have tried this:

<a href="something.html" onclick="console.log(this);">Click me</a&g开发者_如何学Got;

But the console just shows the <a> element.


I think you'd have to define the function in a <script/> tag elsewhere.

Would it be that bad to simply use something like:

 <script type="text/javascript">
    $('#something_link').click(function(e) {
        e.stopImmediatePropagation();
    });
</script>
<a href="something.html" id="something_link">Click me</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜