为什么我不能将动态文本放在名为 foo 的 div 上?以下是 asp.net 代码隐藏中的方法。
StringBuilder script = new StringBuilder();
script.Append("<script type='text/javascript'>");
script.Append(" $(document).ready(function () {");
script.Append(" $('<div id=foo></div>').appendTo('body');");
script.Append(" var dlg = $('#foo');");
script.Append(" dlg.dialog({");
script.Append(" autoOpen: true,");
script.Append(" resizable: false,");
script.Append(" draggable: false,");
script.Append(" modal: true,");
script.Append(" title: 'Información',");
script.Append(" width: 400,");
script.Append(" height: 200,");
script.Append(" buttons: {");
script.Append(" 'Cerrar': function () {");
script.Append(" $(this).dialog('close');");
script.Append(" }");
script.Append(" }");
script.Append(" });");
script.Append(" $('#foo').html(<p>"+info+"</p>);");
script.Append(" });");
script.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "launchModalWindow", script.ToString());
问题出在这一行:
script.Append(" $('#foo').html(<p>"+info+"</p>);");