I’m working on a Google Chrome extension, and I have the HTML of the popup. I have an element called #switch, but document.querySelector(‘#switch’) isn’t working as a selector. It just returns null.
Any ideas on what to do?
document.addEventListener('DOMContentLoaded', function() {
let switchElement = document.querySelector('#switch')
console.log(switchElement)
switchElement.addEventListener('change', () => {
console.log(switchElement)
})
})
I tried adding an event listener for DOM CONTENT LOADED, but that didn’t work.
New contributor
Preston K is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.