While researching how to use onclick, I found an article called “The Bad Practice of href=”#” onclick” so I’ll introduce it.
Bad Example
Search
If there’s a value in the href attribute of an a element, it will try to reference the href attribute value after executing the onclick attribute content.
Also, if # is included, it will navigate to the top of the page.
Good Example
Search
Also, if you’re going to execute an onclick event handler, this writing style is clean and good:
Search
Search
That’s all.
That’s all from the Gemba.