I have been trying to add a click event handler on to a button in my chrome extension. No matter what I try, the function "save" will not activate on button click. The index.html
file looks like this:
<!doctype html>
<html>
<head>
</head>
<body>
<textarea id="notes" rows="4" cols="50"></textarea>
<button id="save-button">Save</button>
<script src="popup.js"></script>
</body>
</html>
And the code to add the event handler on to the button looks like this:
function save() {
console.log('SAVE TEST')
}
document.addEventListener('DOMContentLoaded', function () {
const saveButton = document.getElementById('save-button')
saveButton.addEventListener('click', save);
});
I have confirmed that the saveButton.addEventListener
is being called. I've looked everywhere online and it seems like I am doing things right, but I must be messing up somewhere that I just cannot figure out...