I'm trying to link the JavaScript file to the HTML in this specific way, but it's not working. Not interested in using jQuery for this specific question or referencing the function in html.
// javascript.js
const button1 = document.querySelector(".button1");
button1.onclick = function() {
alert("External JS file works!");
}
<input type="button" value="button1" class="button1"></input>
Clicking the button doesn't show the alert