如何在没有指定html div的情况下使用jquery-ui创建对话框

Dav*_*hao 5 dialog jquery-ui

使用jquery-ui创建对话框非常简单:

<script>
$(function() {
    $( "#dialog" ).dialog();
});
</script>

<div id="dialog" title="Basic dialog">
    <p>This is the default dialog which is useful for displaying information. The dialog window can be   moved, resized and closed with the 'x' icon.</p>
</div>
Run Code Online (Sandbox Code Playgroud)

...但是仍然需要HTML中的div来实现这一点.在道场:

var dlg = new dijit.Dialog({
    title:"dialog",
    style: "width:30%;height:300px;"
});
dlg.show();
Run Code Online (Sandbox Code Playgroud)

如果没有html部分中指定的任何内容,只会做诀窍,jquery-ui可以这样做吗?(我必须在这里使用jquery-ui)谢谢,

大卫

Jus*_*ith 18

虽然我不确定您为什么要打开没有内容的对话框,但您可以轻松地创建一个新的对话框并调用jquery对话框:

$("<div>hello!</div>").dialog();
Run Code Online (Sandbox Code Playgroud)