Skip to content
Advertisement

Very Simple HTML/JavaScript Button Not Working

What should be an incredibly simple button is not working. All I want is for it to log something to the console for some testing purposes, but it refuses to work.

JavaScript

There’s the button in my HTML file, and below is the JavaScript that, as far as I can tell, should be working.

JavaScript

All I want is for the button to call the AddMarker function. I’ve added an even simpler function to make sure AddMarker didn’t have any issues, and it still doesn’t work. Without the window.onload my getElementById returns null, and I experimented with wrapping the entire code with the window.onload, that seemed to change nothing. Everything seems to work with inline JavaScript, but for some reason when accessing the button through the DOM, things stop working. The code below works fine.

JavaScript

This is really frustrating to me as it should be so simple. It’s probably something obvious, but I can’t figure it out for the life of me. Any help is appreciated!

Advertisement

Answer

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement