jquery 模式对话框 onclick?

标签 jquery dialog modal-dialog

我想要这个:

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

当您点击 ClickMe 时发生。

如何做到这一点?

<script type="text/javascript">
$(document).ready(function() {
$('div.thedialog').dialog({ autoOpen: false })
$('#thelink').click(function(){ $('div.thedialog').dialog('open'); });
}
    </script>
</head>
<body>
<div id="thedialog" title="Download complete">
    <p>
        <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
        Your files have downloaded successfully into the My Downloads folder.
    </p>
    <p>
        Currently using <b>36% of your storage space</b>.
    </p>
</div>
<a href="#" id="thelink">Clickme</a>

什么都没发生

最佳答案

不要使用 div.thedialog,而是使用 div#thedialog. 与类名一起使用,# 在使用 ids 时使用。

(另外,如果这是您使用的实际代码,则缺少括号:))

工作代码:

<!doctype html>
<head>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/ui-lightness/jquery-ui.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
    <script type="text/javascript">
$(document).ready(function() {
$('div#thedialog').dialog({ autoOpen: false })
$('#thelink').click(function(){ $('div#thedialog').dialog('open'); });
})
    </script>
</head>
<body>
<div id="thedialog" title="Download complete">
    <p>
        <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
        Your files have downloaded successfully into the My Downloads folder.
    </p>
    <p>
        Currently using <b>36% of your storage space</b>.
    </p>
</div>
<a href="#" id="thelink">Clickme</a>
</body>

关于jquery 模式对话框 onclick?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2353037/

相关文章:

javascript - 需要将 ajax 响应存储到全局变量

javascript - 将一项添加到数组中,而不是使用 javascript 重新列出整个数组

c# - 关闭共享点对话框后如何刷新父页面?

ios - 防止关闭模态 WKInterfaceController

jquery - 如果容器具有特定元素,则更改容器的宽度

javascript - 动态更改 slideToggle 上的 div 高度

visual-c++ - CMenu 和基于对话框的应用程序

android - 是/否对话框和生命周期

jquery - 格式化文本的数据标题中的 HTML 代码

javascript - 如何让多个模态框出现在 while 循环中?