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>

But the console just shows the <a> element.

Answers


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>

Need Your Help

C# Aes ecb pkcs5pad

c# php encryption aes

i need a AES function to encrypt/decrypt with model ecb, PKCS5Padding using an symmetric key(128 bits created with AES parameters)

Less Than operator on string comparison yields same result no matter the situation

c++ string operators string-comparison

I wanted to see if the Less Than operator (&lt;) would work on strings. Well, it did. I started to experiment with it, and it turns out, I got the same result, regardless of the situtaion. The stri...