【发布时间】:2011-05-04 22:17:18
【问题描述】:
我在图片标题中使用 ascii 字符引用 (®) 时遇到问题。当您通过 html 正文设置它时它工作正常,但是当尝试通过 javascript 做同样的事情时不起作用。
检查 sscce:
<style type="text/css">body {background-color:black;}</style>
<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
<p>this image has the correct ascii character title:<br /><img src="http://www.prototypejs.org/images/logo-home.gif" id="img1" title="®" /></p>
<p>but why can't I set the same value via javascript?<br /><img src="http://www.prototypejs.org/images/logo-home.gif" id="img2" /></p>
<script type="text/javascript">
$("img2").title = "®";
</script>
谢谢。
【问题讨论】:
-
啊,我想我明白了.. 任何地方都有“htmlToText”实用功能吗?我不想必须以编程方式创建一个 html 元素只是为了提取文本......
标签: javascript html ascii