문제

I want to insert two texts into one text area using javascript.

I am getting plain text from Wikipedia but I can't seem to two or more article sections into the text area.

I use the code bellow for inserting the text for both sections into the text area.

pText = pText.substring(0, pText.length - 2); //Remove extra newline
pText = pText.replace(/\[\d+\]/g, ""); //Remove reference tags (e.x. [1], [4], etc)
document.getElementById('textarea').value = pText

http://jsfiddle.net/LUTW4/

도움이 되었습니까?

해결책

document.getElementById('textarea').value += pText;

To add old text of the text area and new text , just concate it using +

This is nothing but ,

document.getElementById('textarea').value = document.getElementById('textarea').value + pText;

Fiddle:http://jsfiddle.net/LUTW4/2/

다른 팁

You can append more texts by

 document.getElementById('textarea').value = pText
 document.getElementById('textarea').value += newText

or even join both by

pText = pText+newText;
document.getElementById('textarea').value = pText 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top