如何使用jQuery注入HTML代码? [重复]

问题描述

|                                                                                                                   这个问题已经在这里有了答案:                                                      

解决方法

使用
.html()
代替
.text()
    ,使用
.html()
代替
.text()
。     ,尝试:
$(\'#divname\').html(\"code\");
    ,解决这个问题, 我首先需要一个var htmlCode,将其转换为解码HTML代码,然后使用html函数……谢谢大家。
var htmlCode = $(\"<p/>\").html(\"line:1   3spaces b4&lt;br /&gt;&lt;br /&gt;line:3     5spaces b4&lt;br /&gt;     5spaces b4,line: 4\").text();

$(\"#aaa\").html(htmlCode);