【问题标题】:jquery :Find the new line character and replace it with <br> [closed]jquery:找到换行符并将其替换为 <br> [关闭]
【发布时间】:2013-11-22 11:09:38
【问题描述】:

在我的页面中,表格列之一的 html 如下所示

My world Logistics,\n Hamburg Industriestrasse \n 21107 Megas Sorter HH India

哪里有\n我需要用html标签&lt;br&gt;替换它

在Jquery、javascript中怎么做?

【问题讨论】:

标签: javascript jquery


【解决方案1】:
<script>
var messagetoSend = document.getElementById('x').value.replace(/\n/g, "<br />");
alert(messagetoSend);
</script>

X 是表名。

【讨论】:

  • var messagetoSend = document.getElementById('x').innerHTML.replace(/\\n/g, "&lt;br /&gt;");
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-14
  • 2011-02-24
  • 2011-11-14
  • 1970-01-01
  • 2022-08-07
  • 1970-01-01
相关资源
最近更新 更多