我正在使用 jquery 对话框。在那个框中,有文本字段。所以,在其中一个字段中,我希望文本出现在下一行 一定的值(value)后。在不同的地方,我看到人们使用\n 在第二行显示文本,但我做不到。 这是我的那个文本字段的 HTML
<input id=message class="inputFeild" style="height:60px type="text">
这里是脚本,其中 test1、test2、test3 是我从其他地方获取的一些变量值
var message = "Message is :"+test1+" \n "+"\n new line :"+ test2+"\n again new line " +test3
$(this).find('#message').val(message);
我也这样用过
var text = $('#message');
$(this).find(text).val(message)
还有
$(this).find(text).val("Message is :"+test1+" \n "+"\n new line :"+ test2+"\n again new line " +test3)
但是当我在 console.log 中使用相同的内容时,我能够看到第二行。
如何在所需点后的第二行中断文本?
最佳答案
您可以使用 textarea 代替输入 对 texareas 大小使用 cols 和 rows 属性:
<textarea rows="4" cols="50">
关于javascript - 在所需点后中断输入字段中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43543169/