jquery - 如何打开 JQuery UI 弹出窗口 onclick

标签 jquery jquery-ui popup

我有简单的 html 页面:

<html>
<head>
<title></title>
</head>
<body>
  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>


    <script type="text/javascript">
        $(document).ready(function () {
            $("#OpenDialog").click(function () {
                $("#dialog").dialog({modal: true, height: 590, width: 1005 });
            });
        });
    </script>
    <a id="#OpenDialog" href="#">Click here to open dialog</a>
    <div id="dialog" title="Dialog Title">
        <p>test</p>
    </div>

</body>
</html>

我需要隐藏弹出内容,然后单击链接时打开一个对话框。

我的代码有什么问题吗?

谢谢!

最佳答案

如果您想像在 $ 中使用的那样使用 jQuery 选择器,则元素的

id 中不应包含 # ("#OpenDialog").click(

改变

<a id="#OpenDialog" href="#">Click here to open dialog</a>    

 <a id="OpenDialog" href="#">Click here to open dialog</a>

关于jquery - 如何打开 JQuery UI 弹出窗口 onclick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11906342/

相关文章:

jQuery 删除 div

python - 在 Kivy 中制作(继续)选项屏幕

javascript - HTML select - 在 HTML 中显示值属性但保留选项文本

javascript - 获取 json 数据中的嵌套映射

javascript - 通过大量局部 View 动态更改文本

jQuery 在鼠标悬停时暂停延迟计时器

javascript - 对元素 jQuery 进行回调

javascript - 单击行上的行选择但不单击超链接单击 jquery 数据表中的列之一?

python - Tkinter 让我的弹出窗口位于屏幕中间

python - 如何禁用 "Save Password for this website"Selenium Python 语法