HTML TextArea 中的换行符
Newline character in HTML TextArea
参考以下问题下的可用答案 -
What character represents a new line in a text area
textarea 中的换行符应该是 CRLF,尽管在带有换行符的 textarea 中输入数据只会生成 \n,如下面的代码片段所示 -
<textarea id="one" onchange="document.getElementById('contentdiv').innerText=JSON.stringify(document.getElementById('one').value)"></textarea>
<button onclick="document.getElementById('contentdiv').innerText=JSON.stringify(document.getElementById('one').value)">Read Content</button>
<div id="contentdiv"></div>
关于此处看到的更改行为,文本区域的定义标准中是否有 references/changes?
您提供的 link 实际上有答案。
The textarea element value exists in three variants:
- the raw value as entered by the user, unnormalized; it may contain CR, LF, or CR LF pair;
- the internal value, called “API value”, where
line breaks are normalized to LF (only);
- the submission value, where line breaks are normalized to CR LF pairs, as per Internet conventions.
你的案例是 2
参考以下问题下的可用答案 - What character represents a new line in a text area
textarea 中的换行符应该是 CRLF,尽管在带有换行符的 textarea 中输入数据只会生成 \n,如下面的代码片段所示 -
<textarea id="one" onchange="document.getElementById('contentdiv').innerText=JSON.stringify(document.getElementById('one').value)"></textarea>
<button onclick="document.getElementById('contentdiv').innerText=JSON.stringify(document.getElementById('one').value)">Read Content</button>
<div id="contentdiv"></div>
关于此处看到的更改行为,文本区域的定义标准中是否有 references/changes?
您提供的 link 实际上有答案。
The textarea element value exists in three variants:
- the raw value as entered by the user, unnormalized; it may contain CR, LF, or CR LF pair;
- the internal value, called “API value”, where line breaks are normalized to LF (only);
- the submission value, where line breaks are normalized to CR LF pairs, as per Internet conventions.
你的案例是 2