Javascript InnerHTML Erases Data In Form Elements

前端 未结 4 1850
灰色年华
灰色年华 2021-01-22 05:32

I have this form with a button that allows you to add fields to the form.

4条回答
  •  无人共我
    2021-01-22 05:50

    Give the

      element an ID:

        ...

      Then change the first line in your function to:

      var d=document.getElementById("answers");
      

      Once you make the changes mentioned above, it should work. I have tested it in Firefox, Chrome, Safari, and IE8. And as others have mentioned, you should also correct your spelling of "label".

提交回复
热议问题