Html 保留换行符-输入类型=";“文本”;
我正在编写一个复制粘贴脚本,除了在我要复制的段落中没有换行符外,该脚本可以正常工作。因此,粘贴的结果是在一行上显示所有文本Html 保留换行符-输入类型=";“文本”;,html,input,Html,Input,我正在编写一个复制粘贴脚本,除了在我要复制的段落中没有换行符外,该脚本可以正常工作。因此,粘贴的结果是在一行上显示所有文本 <input type="text" value="This is the first line This is the second paragraph This is the third paragraph" id="myInput"> <button onclick=&qu
<input type="text" value="This is the first line
This is the second paragraph
This is the third paragraph" id="myInput">
<button onclick="myFunction(event)">Copy</button>
复制
示例:从按钮复制时,它粘贴为:
这是第一行这是第二段这是第三段
相反,如果可能的话,我希望在段落之间插入一行我想你可以使用textarea而不是input
<textarea id="myInput">This is the first line
This is the second paragraph
This is the third paragraph</textarea>
这是第一行
这是第二段
这是第三段
您是否尝试在每个换行符上添加\n
?例如:这是第一行\n
太好了,非常感谢!!