I have this simple javascript function:
Write the code as follows:
Once your click listener is set, your previous if statement's location wasn't executed anymore. Only the code inside the on click function.
Alternatively, you can unbind the onClick listener instead of setting popup = '1'
. Try the following:
Much cleaner, and as Mathletics has mentioned, cleans unnecessary callbacks from memory.