<script>
$('#textarea_').on('keyup', function() {
var textareaContentWithJquery = $('#textarea_').val();
var textareaContentWithJavascript = document.getElementById('textarea_').value;
});
</script>
<textarea cols="20" id="textarea_" name="textarea_" rows="2">
Some text in textarea here is created without pressing enter,
just plain text. But how can i get the position
of newline markup from textarea so that i can put <br> there?
</textarea>
我从textarea那里得到价值(纯文本); textarea中的一些文本是在没有按下输入的情况下创建的,只是纯文本。但是我怎样才能从textarea获得换行标记的位置,以便我可以在那里放置<br>
?textarea中的换行标记
如果我按下输入textarea并传递到新行然后它会很容易,因为在我按Enter键的地方会有一个\n
,但是当我只是添加文本并让textarea将文本换行到新行然后我没有\n
那里的文字。
我需要它是这样的(而不是纯文本);
Some text in textarea here is created without pressing enter,\n
just plain text. But how can i get the position\n
of newline markup from textarea so that i can put <br> there?\n
So i would easily replace \n with <br>
Some text in textarea here is created without pressing enter,<br>
just plain text. But how can i get the position<br>
of newline markup from textarea so that i can put <br> there? <br>
textareaContentWithJquery和textareaContentWithJavascript给出了相同的结果,我的意思是没有\n
标记。所以他们没用。
您是否使用PHP中的textarea的显示数据并且它在这些HTML实体? – hmd
你的第一个问题是,一个新行被表示为'\ n'不是'/ n' –
是的正确...抱歉 – lowdegeneration