formタグ内でonclick属性の関数が同じ名前だと動作しないサンプル

<script>
function hello() {
  alert('hello')
}
</script>
<form onsubmit="return false;">
  <input type="submit" name="hello" onclick="hello()">
</form>

addEventListenerなら動作する

<form onsubmit="return false;">
  <input type="submit" name="hello" id="h">
</form>

<script>
function hello() {
  alert('hello')
}
const h = document.getElementById('h')
h.addEventListener('click', hello)
</script>

元記事を表示する