Skip to content

Instantly share code, notes, and snippets.

@amycruz97
Last active Sep 28, 2020
Embed
What would you like to do?
// we created a myBtn function stating that when ever we click btn, it should alert 'you clicked on the button class'
function myBtn() {
alert('you clicked on the button class')
};
// btn class does not exist in our html page therefore this will throw an error of addEventListener of null
const btn = document.querySelector(".btn").addEventListener('click',myBtn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment