I have already used addEventListener for other context but in this context, I failed to see why it doesn't not seem to work :
UPDATE : have fixed [0] missing
https://jsfiddle.net/gyy37w7z/2/
<!DOCTYPE html>
<html>
<body>
<table>
<tbody>
<tr>
<td>
<form action="demo_form.asp">
Username: <input type="text" name="usrname" class="myClass"><br>
<input type="submit" value="Submit">
</form>
</td>
</tr>
</tbody>
</table>
</body>
</html>
script :
button = document.getElementsByClassName("myClass")[0];
function hello() {alert('hello')};
button.addEventListener("click",hello);