admin管理员组文章数量:1397093
I have a textarea
and I do console.log($("textarea").val())
, the result can be
abc
123
And I have an input, i want to concate the value with the value of textarea, like this
input_value
abc
123
I tried <br>
but the br will appear which is not I want. How to make newline in concatenation? use \n
?
I have a textarea
and I do console.log($("textarea").val())
, the result can be
abc
123
And I have an input, i want to concate the value with the value of textarea, like this
input_value
abc
123
I tried <br>
but the br will appear which is not I want. How to make newline in concatenation? use \n
?
-
Did you try
\n
? what happened? – epascarello Commented Aug 21, 2016 at 13:51 -
You ask for
\n
but didn't try it? It's workine fine. – mxlse Commented Aug 21, 2016 at 13:51
2 Answers
Reset to default 3Use \n
instead of <br>
. Like that:
console.log($("input").val() + '\n' + $("textarea").val());
You can try something like this:
alert('abe \n' + 123);
\n Seems to do the trick for you.
Further Reading: http://www.w3schools./jsref/jsref_regexp_newline.asp
本文标签: javascriptadding newline in string concatenationStack Overflow
版权声明:本文标题:javascript - adding newline in string concatenation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744148117a2592932.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论