从 textarea 中删除换行符和空格

Remove line-breaks and spaces from textarea

<textarea rows='5' cols='50' id='content'></textarea>
<input type='button' value='Extract Text' onclick='someFunction()'/>

假设这两个 html 元素。我的问题如下:

假设用户在 textarea 字段中输入了类似这样的内容,与键入的内容完全相同。所有换行符和 spaces。 (是的,这是 Python :P)

if (...):  
   print "Hello everyone!"
else:
   print "Dudes help me out!"

我的 objective 是创建一个 JavaScript 函数,该函数删除所有 space 和换行符(使用 'Enter' 键入)和 returns space-更少的字符串。类似于 "ThisIsASampleText"。我使用 document.getElementById('content').valuemyString.replace(/\s+/g, '') 删除了 space。不能让它工作。有任何想法吗?

此致

这是一个现场演示,演示如何使用您描述的正则表达式从文本区域中删除文本中的所有空格:

function someFunction() {
    var output = document.getElementById("content").value;
    output = output.replace(/\s/g, "") 
    document.getElementById("output").innerHTML = output;
}
<textarea rows='5' cols='50' id='content'></textarea>
<input type='button' value='Extract Text' onclick='someFunction()'/>
<div id="output"></div>

JSFiddle 版本:https://jsfiddle.net/afy5v66x/1/