Skip to content

Instantly share code, notes, and snippets.

Last active Sep 28, 2020
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