How can I append a list of text into a textarea?
var Alltext = "";
function addText(text) {
Alltext += text
}
document.getElementById("alltext").value = Alltext;
<textarea id="alltext"></textarea>
<ol>
<li onclick="addText('Hello')">Hello</li>
<li onclick="addText('World')">World</li>
<li onclick="addText('Earthlings')">Earthlings</li>
</ol>
This is quite inefficient, as the list is actually very long. The text added is exactly the value I see in the HTML, so I assume there's no need to type it twice.
Are there any better methods?
TextArea. e.g.textArea.setRangeText (newText, textArea.textLength, textArea.textLength);