我是javascript的新手,正试图在页面打开时打开一个简单的对话框,但它只是显示
对话框的文本,就像它是一个普通的段落,没有对话框。这是我的index.html:
<html xmlns=\ "http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<head>
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
<script type='text/javascript' src='js/jquery.js'></script>
<title>Welcome to Jetty-9</title>
<style type="text/css" title="maincss">
@import url(maincss.css);
</style>
<script type="text/javascript">
$(function() {
$("#dialog").dialog();
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
</body>
</html>而且我的maincss.css只是在正文中放置了一个背景图像,而js/jquery.js文件是jquery的最新版本,我通过加载页面、查看页面源代码,然后通过单击打开js文件来确保它被正确链接
发布于 2013-07-02 02:21:46
您需要包含jQuery UI才能利用该对话框。
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
发布于 2013-07-02 02:21:31
您必须在JQuery主文件之后导入JQuery UI的api
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>这种方式应该是有效的:
<html xmlns=\ "http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<head>
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
<script type='text/javascript' src='js/jquery.js'></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<title>Welcome to Jetty-9</title>
<style type="text/css" title="maincss">
@import url(maincss.css);
</style>
<script type="text/javascript">
$(function() {
$("#dialog").dialog();
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
</body>
</html>发布于 2013-07-02 02:21:41
假设您正在尝试使用jquery-ui dialog,如果是这样的话,您需要包含jquery-ui文件
这些是来自CDN的最新版本
http://code.jquery.com/ui/1.10.3/jquery-ui.js
http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css如果需要,您可以选择不同的主题
https://stackoverflow.com/questions/17411057
复制相似问题