如何在弹出窗口中显示html的内容?
这是我的弹出窗口。
$(document).ready(function(){
$(".popup").click(function(){
var value = $(this).attr("value");
$.post("/news/index.php?r=news/detail&id="+value,function(data,status){
if(data != null){
var obj = jQuery.parseJSON(data);
var description = obj.description;
$('#description').text(description);
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
}
});
});
});
的index.php
<div id="dialog-message">
<table>
<tr>
<td>short Content</td>
<td id="description"></td>
</tr>
</table>
</div>
对话框中的文字显示:
<html> <head> <title></title> </head> <body> <p>test for description</p> </body> </html>
结果,有没有办法通过对话框中的html声明显示文本'test for description'?
非常感谢
答案 0 :(得分:0)
.text()
将转义HTML字符,以便将HTML显示为实际文本而不是浏览器呈现的标记。
使用.html()
代替,它应该有效(尽管我很想删除你插入的HTML,只插入<body>
标签之间的内容)
答案 1 :(得分:0)
您可以使用html()
代替text()
$('#description').html(description);
而不是
$('#description').text(description);