HTML button avoid submit If you had the problem that the button makes a submit but you just want to run a JavaScript you had to add the type “button” to avoid this, like this: <button type="button" onclick="run();">TRY</button>