我有简单的 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/