Skip to content
Advertisement

JavaScript function will open div tag; second JavaScript function does not close it however

I have been browsing here and looking at similar problems, however none of the solutions seem to work. This is also my first posted question.

JavaScript
This is just a pseudo code but I ran this and it works(or doesn’t work) exactly how mine does. I do not understand why the closeEmail function is not working.

Advertisement

Answer

Your code isn’t working because of event bubbling

I’ve updated your code to be more legible by putting your element in a var

JavaScript

Changing your button element to this will stop the default functionality

JavaScript

Run the snippet below to see it in action.

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