Skip to content
Advertisement

TypeError: Cannot read property ‘addEventListener’ of null when i want to add new elements to my database

I created a form to create new post from the auth users however im getting this error “Uncaught TypeError: Cannot read property ‘addEventListener’ of null” and cant seem to know why my script is at the end of the HTML and its an external file, I’ve used eventListener in other places and it work just fine. I’ve even checked for spelling errors but to no avail.

JavaScript

this is my html

JavaScript

Advertisement

Answer

You have a form within a form, which is bad and I think in this case, a typo

Try removing <form class="modal-content animate" method="post"> and see if that clears things up

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