Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 显示带换行符的输出文本区域_Javascript_Html_Regex_Textarea - Fatal编程技术网

Javascript 显示带换行符的输出文本区域

Javascript 显示带换行符的输出文本区域,javascript,html,regex,textarea,Javascript,Html,Regex,Textarea,我试图显示文本区域的内容,包括任何换行符 var text = document.getElementById("textInput").value ; text = text.replace(/[\n|\r\n]/g,"<br />"); document.getElementById("voorwoord-voorbeeld-tekst-links").firstChild.nodeValue = text; var text=document.ge

我试图显示文本区域的内容,包括任何换行符

  var text =  document.getElementById("textInput").value    ;    
  text = text.replace(/[\n|\r\n]/g,"<br />");
  document.getElementById("voorwoord-voorbeeld-tekst-links").firstChild.nodeValue = text;
var text=document.getElementById(“textInput”).value;
text=text.replace(/[\n |\r\n]/g,“
”); document.getElementById(“voorwoord-voorbeeld-tekst链接”).firstChild.nodeValue=text;
“替换”功能正常,但会显示: dfsdsf
s
df
sdf
而不是中断


我怎样才能解决这个问题?我搜索了整个web,但找不到它。

请尝试设置元素的innerHTML:

document.getElementById("voorwoord-voorbeeld-tekst-links").firstChild.innerHTML = text;

真的,整个网络@格多伦,整个蜘蛛网在他的书架上。