问题描述
我有一个我怀疑是一个简单的问题,搜索后我怀疑我的问题的答案是否定的,但要仔细检查......
I have what I suspect to be a simple question and after search I suspect the answer to my question to be no, but to double check...
是否可以在不设置 DIV 的情况下使用 Jquery ui 对话框?
Is it possible to use the Jquery ui dialog with out setting up a DIV?
ie 而不是..
$(function() { $( "#dialog" ).dialog();});...
<div id="dialog" title="我真的需要这个吗?">为了传递一个简单的信息,需要输入很多字</div>
是否有可能只是有类似...的东西
Is it possible just to have something like...
$(function(quickly) { $( "#dialog" ).dialog('这会容易得多');});...
并在需要时使用 quick() 类型的东西调用它.
and call it with a quickly() type thing when needed.
您可能会注意到,我可能会混淆 Javascript,并通过反复试验尽力找到适合我的解决方案.
You may note that I muddle may way through Javascript and do my best through trial and error to hit on a solution that works for me.
我想,我在问我是否可以以类似的方式使用对话框...
I suppose, I'm asking if I can somehow use dialog in a similar fashion to...
alert("这很简单")
...所以我可以在需要时向用户发出警报,而不是点击 url 或按下按钮.
...so I can call an alert to the user whenever I need to, rather than on url click or button press.
希望以上内容有意义,我怀疑我将不得不坚持丑陋的标准警报,但如果有简单的解决方案,请告诉我.
Hopefully the above make sense and I'll suspect I'll have to stick with the ugly standard alert but do let me know if there is a simple solution.
谢谢
推荐答案
希望对大家有帮助,你可以直接把html传给dialog,像这样:
I hope this helps somebody, you can pass html to dialog directly, like this:
$("<p>Hello World!</p>").dialog();
这样您就不必预先构建 div,您可以使用:
so this way you don't have to have a pre-builded div, you could use:
$("<div>My div content</div>").dialog();
将结束标记更改为 </div>
而不是 </p>
changed end tag to </div>
instead of </p>
这篇关于Jquery-UI 对话框 - 在没有 DIV 的情况下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!