What href value to use for JavaScript links: "#" or "javascript:void(0)"?
Hello everyone! I'm a beginner frontend developer and often encounter situations where I need to make a link that doesn't navigate to another page but executes some JavaScript code (open a modal window, submit a form via AJAX, show a menu). Usually I use `` and write `event.preventDefault()` in the click handler. But recently I saw in someone else's code ``. And now I don't understand which option is more correct.
Currently I do this:
```html
Open modal
```
But this looks hacky. I've heard that `javascript:void(0)` solves the problem without returning false. But is there a difference in performance? What's better for accessibility? Maybe I shouldn't use a link at all and use `
No answers yet.
Log in to leave an answer