Skip to content

Instantly share code, notes, and snippets.

@amycruz97
Last active September 28, 2020 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amycruz97/af427a69dec50210572b0aabccb048f2 to your computer and use it in GitHub Desktop.
Save amycruz97/af427a69dec50210572b0aabccb048f2 to your computer and use it in GitHub Desktop.
// 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