I want my button to trigger a download of a PDF file when clicked. However, I am having trouble getting the button to fire the function when clicked. For now, I am just wanting the button to console.log "it works"
I have selected the correct element, and defined the type as "button", and am able to console.log the button. But when attaching the button.onclick()= function{ console.log("it works");}; it does not trigger the console.log in the console. I have also put the onclick function into a window.onload function.
<div id="resume" class="resume">
<button type="button" id="resume-button" class="resume-button">RESUME</button>
</div>
--JavaScript--
var button = document.querySelectorAll('.resume-button');
window.onload = function(){
button.onclick = function(){
console.log("yay its working");
}; }
I am expecting the console to output "it works" when the button is clicked, but nothing happens when clicked.