0

我有一些 html 内容要在 jquery 对话框 onclick 中显示。这是示例代码

html代码(内部php):

<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");
  }
 }
 });
  }

如果 $toperrors 包含一个字符串,则代码运行良好,没有任何问题。

但是如果我将 html 内容分配给 $toperrors 变量。然后将html内容打印在网页
本身上。也许它没有隐藏在 div 中的 style='display:none' 中。任何帮助将不胜感激。谢谢。

4

1 回答 1

0

strip_tags() 或 htmlentities()

<div id = '".strip_tags($id)."' style='display:none' >".$toperrors." </div> 
于 2013-10-20T18:48:53.560 回答