TCG
TCG

Reputation: 540

How to disable an A hyperlink in Chrome like in IE

In IE a <a href="javascript:;></a> can be disabled by setting property disabled="true", but it does not work for Chrome. I don't want it trigger any event while clicking. (event.preventDefault(), event.stopPropagation() don't work for me).
How can I disable it in Chrome just like in IE?

Thanks!

Upvotes: 0

Views: 695

Answers (1)

dcangulo
dcangulo

Reputation: 2107

Instead of using <a href="javascript:;></a>

Why not use, <a onclick="javascript:;></a>?

function helloWorld() {
  alert("Hello World!");
}
<a onclick="helloWorld()">Click Me</a>

Upvotes: 1

Related Questions