所以我有这个代码将创建一个新的表单输入字段,它在一个javascript方法中,在Google Maps窗口中的每次鼠标点击时触发。现在它是在一行上创建每个表单,我如何让每个新表单显示在前一个表单下面?
感谢您的帮助!
JavaScript:
//Creates new input boxes for each new marker
var newForm = "Checkpoint " + markerId + " Name:<input type='text' id=" + markerId + " />";
document.getElementById("divForms").innerHTML = document.getElementById("divForms").innerHTML + newForm;
HTML:
<form id="divForms"></form>
答案 0 :(得分:1)
您是否尝试将换行符<br />
添加到newform
的末尾:
var newForm = "Checkpoint " + markerId + " Name:<input type='text' id=" + markerId + " /><br />";
或者在分配innerHTML
:
document.getElementById("divForms").innerHTML = document.getElementById("divForms").innerHTML + '<br />' + newForm;