如何打开JQuery UI弹出窗口onclick [英] How to open JQuery UI popup onclick
本文介绍了如何打开JQuery UI弹出窗口onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的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>
我需要隐藏弹出内容,然后单击链接打开一个对话框.
我的代码有什么问题?
谢谢!
如果要像在$("#OpenDialog").click(
jQuery selector,则元素的解决方案
id
不应该包含#
>
更改
<a id="#OpenDialog" href="#">Click here to open dialog</a>
收件人
<a id="OpenDialog" href="#">Click here to open dialog</a>
I have simple html page:
<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>
I need to have popup content hidden and when click on the link open a dialog.
What I'm wrong with in my code?
Thanks!
解决方案
id
of element is not supposed to have #
in it if you want to use jQuery selector
as you used in $("#OpenDialog").click(
Change
<a id="#OpenDialog" href="#">Click here to open dialog</a>
To
<a id="OpenDialog" href="#">Click here to open dialog</a>
这篇关于如何打开JQuery UI弹出窗口onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文