使用jquery创建对话框时,如何隐藏对话框div?

发布于 2024-08-26 03:16:07 字数 377 浏览 3 评论 0原文

我正在创建一个如下页面所示的对话框:

http://jqueryui.com/demos/dialog/ #modal-confirmation

(单击查看源代码)

底部的 是放置在对话框中的 div。该对话框在由 javascript 调用时工作正常,但在加载时该对话框在页面底部可见。 (减去 javascript 函数调用时应用的所有样式)

如何隐藏 div 并仍然允许对话框使用它?我尝试过设置 style="visibility:hidden" 但这会阻止 javascript 调用时显示它。

I am creating a dialog like in this page:

http://jqueryui.com/demos/dialog/#modal-confirmation

(click view source)

on the bottom is the div that gets placed in the dialog. The dialog works perfect when called by the javascript but the dialog is apparent at the bottom of the page when it loads. (minus all the styling that gets applied when it is called by the javascript function)

How can I hide the div and still allow the dialog to use it? I have tried setting style="visibility:hidden"
but that prevents it from being shown when called by the javascript.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

念﹏祤嫣 2024-09-02 03:16:07

这可能是一个愚蠢的问题,但是您是否尝试过 “display:none;”而不是 "visibility:hidden" ?我必须为我正在从事的项目解决同样的问题,并且我相当确定 display:none 有效。

您还可以使用该

$(foo).dialog({ autoOpen: false });

选项“初始化”对话框(从而隐藏它和所有好东西)。唯一的问题是,您可能会在页面加载时看到对话框“闪烁”,但在 jQuery 有机会隐藏它之前。

This may be a stupid question, but instead of "visibility:hidden" have you tried "display:none;"? I had to solve the same problem for a project I'm working on and I'm reasonably sure display:none worked.

You can also use the

$(foo).dialog({ autoOpen: false });

option to "initialize" the dialog (thus hiding it and all that good stuff). The only catch is, you'll probably see the dialog "flicker" as the page loads but before jQuery has a chance to hide it.

人疚 2024-09-02 03:16:07

您可以尝试以下对我有用的方法:

$("#form-dialog").dialog("close");

You can try the following it works for me:

$("#form-dialog").dialog("close");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文