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>
精彩评论