我有这个变量template="<div>...</div>"
我想在对话框中显示以下html代码:
<div id="dialog" title="Basic dialog">
<p id="templates"></p>
</div>
<script>
$("#templates").html(template);
$( "#dialog" ).dialog({
height: auto,
width: 800,
modal: true,
// ...
});
</script>但它不起作用。
如何在对话框中添加自定义html?
发布于 2014-10-30 21:57:27
这应该可以满足您的目的:
function PopModal(StuffToAppearInModal) {
$('<div>' + StuffToAppearInModal+ '</div>').dialog({
height: auto,
width: 800,
modal: true,
});
}去掉变量中的"head“和"html”标签,然后这样调用它:
PopModal("hey this is going to appear in my <font color='Red'>modal</font>. html controls work, too like this: <input type='text' id='tbTest'/>");发布于 2014-10-30 21:43:50
您可以使用wireframes或不带<html><head>...</head></html>的附加代码,因为它被确定为网页。
发布于 2014-10-30 22:38:06
只有有效的html内容才会被解释为html函数中的参数。如果不是,它将被过滤。在您的示例中,过滤器只留下"...“你的内容中。
有关其他(有效) html内容,请参阅example。
var template="<table style=\"border:solid red 2px;\"><tr><td><u>Test</u></td></tr></table>";
$("#templates").html(template);
...https://stackoverflow.com/questions/26654435
复制相似问题