Writing text on “div” using JavaScript

后端 未结 10 2534
难免孤独
难免孤独 2021-01-04 02:11

I\'m having some trouble whenever I want to add some text to my div tag, here\'s my code:




10条回答
  •  旧时难觅i
    2021-01-04 02:44

    This is because you use not just a regular button but a submit button which by default submits the form to the server. You can see that your comment is submitted via URL as you didn't specify the method(GET and POST and GET is default).

    Simply write:

    onclick="writeComment();return false;"
    

    Returning FALSE prevents from default behaviour - submitting the form.

提交回复
热议问题