1
我的js文件在前端輸出包含上標標籤的文本。問題是在瀏覽器上<sup>
和®
不是渲染,而是將標籤本身顯示爲文本。任何解決方案謝謝!appendchild中的上標html標籤
var rName="Something<sup>®</sup>";
var rURL="http://www.google.com";
var rAA=1;
function addResult(rName, rURL, rAA)
{
var node=document.createElement("li");
var linkNode=document.createElement("a");
node.setAttribute("id", rAA);
node.setAttribute("class", "searchListing");
node.setAttribute("onclick", "window.open('"+rURL+"','_self');");
linkNode.setAttribute("href", rURL);
linkNode.setAttribute("target", "_self");
var textnode=document.createTextNode(rName);
node.appendChild(textnode);
document.getElementById("search_list_results").appendChild(node);
document.getElementById(rAA).appendChild(linkNode);
}
[問題的jsfiddle演示(http://jsfiddle.net/u2f2K/) – 2013-03-27 09:42:52