The problem happened because I was trying to bind a HTML
element before it was created.
My script was loaded on top of the HTML
and it needs to be loaded at the bottom of my HTML
code.
Thanks for your attention James Allardice.
A possible workaround is using defer="defer"
<script src="script.js" type="text/javascript" defer="defer"></script>
Use this if the script is not going to generate any document content. This will tell the browser that it can wait for the content to be load before loading the script.
Hope it helps.