Ask HN: Href=“#” VS href=“JavaScript:;”
and which one it's better to use on the links with JavaScript attached to them (nothing else, JS only).
I know it's not the correct use, it should be a "button", but I really need to use <a>.
Thank you.
and which one it's better to use on the links with JavaScript attached to them (nothing else, JS only).
I know it's not the correct use, it should be a "button", but I really need to use <a>.
Thank you.
[+] [-] twobyfour|8 years ago|reply
If you can't put a URL in it, use a different element. Why can't you use <button>? It's definitely the correct element for something that takes an action. In a pinch, fall back on <span>?
[+] [-] optikals|8 years ago|reply
[+] [-] savethefuture|8 years ago|reply
[+] [-] optikals|8 years ago|reply