【发布时间】:2012-10-20 20:20:35
【问题描述】:
我能够动态生成一个 Unicode 字符并将其插入到 <div> 中,方法是使用像 &#x00f0; 这样的序列,但现在我想将此输入作为转义序列检索,而不是字符本身。
<button id="insertDh">insert funny d to mytext</button>
<div id="mytext"><i>mytext: please click button above</i></div>
<hr>
<textarea id="theSource"></textarea>
<button id="getSource">get mytext's source</button>
$("#insertDh").click(function() {
$("#mytext").html("ð");
});
$("#getSource").click(function() {
$("#theSource").val($("#mytext").html());
});
也就是说,当我点击“get mytext's source”时,我想用&#x00f0;而不是ð来填写textarea。这可能吗?如果有,怎么做?
【问题讨论】:
标签: javascript jquery unicode