Javascript 无法在Jquery对话框中显示html内容
我有一些html内容要在jquery对话框onclick中显示。下面是示例代码 html代码(php内部): 如果$toperrors包含字符串,则代码工作正常,没有任何问题 但如果我将html内容分配给$toperrors变量。然后在web上打印html内容Javascript 无法在Jquery对话框中显示html内容,javascript,php,jquery,html,dialog,Javascript,Php,Jquery,Html,Dialog,我有一些html内容要在jquery对话框onclick中显示。下面是示例代码 html代码(php内部): 如果$toperrors包含字符串,则代码工作正常,没有任何问题 但如果我将html内容分配给$toperrors变量。然后在web上打印html内容 页面本身。也许它并没有在div中使用style='display:none'隐藏。 任何帮助都将不胜感激。谢谢 strip_tags()或htmlentities() “$toperrors。” 除了纯字符串之外,您不应该给html id
页面本身。也许它并没有在div中使用style='display:none'隐藏。 任何帮助都将不胜感激。谢谢 strip_tags()或htmlentities()
“$toperrors。”
除了纯字符串之外,您不应该给html id任何东西。否则你迟早会遇到问题。你能举一个导致这种行为的html输出的例子吗?由于复制粘贴,html内容不是正确的html内容。我正在使用一些html净化器。但在网页上打印的格式还可以。由于我的公司NDA,我不能禁用输出,抱歉。我想在这种情况下,输出会破坏html结构,因此css无法正确地定位您的div,因此内容会显示而不是隐藏。是的,您所说的听起来很有说服力。你知道怎么过来吗?嗨,谢谢你的快速回复。但这没用。抱歉,$toperrors是包含html内容的变量,而不是$id。当$toperrors包含在浏览器上打印的html内容时,它会显示出来。
<div id = '".$id."' style='display:none' >".$toperrors." </div>
<td align='center' onclick='toperrors($id);' > <img src='images/minimize.jpg' width=30
height=20 ></img> </td>
function toperrors(str){
$("#dialog").html("");
$("#dialog").html($("div#"+str).html());
$("#dialog").dialog({
title: "Top errors",
modal: true,
width: "800px",
height: 400,
buttons:
{"OK":function() {
$(this).dialog("close");
}
}
});
}
<div id = '".strip_tags($id)."' style='display:none' >".$toperrors." </div>