[英]escape special characters from html
我正在创建一个 html 表。
<table class=" table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Remarks</th>
</tr></thead>
<tr>
<td> hello <hi> html </td>
</table>
当我运行上面的代码时,我得到一个类似“hello html”的结果。 我需要显示全文,如" hello <hi> html "
使用html 实体:
<td>hello <hi> html</td>
由于您标记了“Java”,我建议您使用Commons Text
库将 html 字符转换为实体。
你可以像这样定义一个script
:
<script>
function loadPage() {
document.body.querySelector("td").innerText = unescape(escape(document.body.querySelector("td").innerHTML));
}
</script>
并添加
onload="loadPage();"
到body
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.