我一直试图找出如何将新行添加到输入标记的值中。
...
<div id="heroDisplay">
<form>
Super Powers:<br> <input id="superpowers" type="text" readonly />
</form>
</div>
...
var superpowersDiv = document.getElementById("superpowers")
for (var i=0; i<heroObj.superpowers.length; i++)
{
superpowersDiv.value += heroObj.superpowers[i]
superpowersDiv.value += "<br/>"
//I've also tried adding "\n" and "\r"
}
Output: X-Ray Vison<br/>Flying<br/>...
OR
Output: X-Ray Vison\nFlying\n...
有什么建议吗?