Ask HN: Href=“#” VS href=“JavaScript:;”
Sorry for my silly question, can you tell me if there's a difference between href="#!" and 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.
4 comments
[ 3.1 ms ] story [ 18.8 ms ] threadIf 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>?