如何使用 bootstrap 读取文本区域表单中的新行?

How to read new line in a textarea form using bootstrap?

我正在使用 Twitter 制作表格-bootstrap

其中一个是支持多行文本的表单控件

<textarea class="form-control" id="resumen" rows="1"></textarea>

然后我看了内容

texto = $('#resumen').val()+'\r\n'

例如,如果用户输入 id resumen 表单:

hello world 
hello world again

texto = hello world hello world again

如何读取表单中的新行?

完整的字符串是一行,不读用户添加(回车)的'new lines'。

我想在用户输入时读取不同行的完整字符串 我该怎么做?

那里有新行,如果您在控制台中读取并打印该输入字符串,您将看到新行。

如果您想在 html 中打印该输入字符串,则将这些新行替换为 <br>

如果你想玩每一行把它们分成数组

<textarea id="textarea"></textarea>
<a href="#!" id="read" onclick="readTextArea()">read</a>

<script type="text/javascript">
  function readTextArea () {
    var data = $("#textarea").val();
    var dataNlToBr = data.replace(/\r?\n/g, '<br>');
    var dataArray = dataNlToBr .split('<br>');
    console.log(data);
    console.log(dataNlToBr);
    console.log(dataArray);

  }
</script>