I\'m having some trouble whenever I want to add some text to my div tag, here\'s my code:
When you click on the submit button the form is submitted, causing the whole page to reload. You need to return false from the onclick of the submit button to prevent it:
Or, if you don't want the button to ever submit the form change type="submit"
to type="button"
.
PS. It's bad practice to use the onclick attribute. Instead bind a handler to the click event using pure JS.