首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加载页面时无法打开jQuery对话框

加载页面时无法打开jQuery对话框
EN

Stack Overflow用户
提问于 2013-07-02 02:19:29
回答 5查看 360关注 0票数 0

我是javascript的新手,正试图在页面打开时打开一个简单的对话框,但它只是显示

对话框的文本,就像它是一个普通的段落,没有对话框。这是我的index.html:

代码语言:javascript
复制
<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文件来确保它被正确链接

EN

回答 5

Stack Overflow用户

发布于 2013-07-02 02:21:46

您需要包含jQuery UI才能利用该对话框。

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

票数 1
EN

Stack Overflow用户

发布于 2013-07-02 02:21:31

您必须在JQuery主文件之后导入JQuery UI的api

代码语言:javascript
复制
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

这种方式应该是有效的:

代码语言:javascript
复制
<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>
票数 0
EN

Stack Overflow用户

发布于 2013-07-02 02:21:41

假设您正在尝试使用jquery-ui dialog,如果是这样的话,您需要包含jquery-ui文件

这些是来自CDN的最新版本

代码语言:javascript
复制
http://code.jquery.com/ui/1.10.3/jquery-ui.js
http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css

如果需要,您可以选择不同的主题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17411057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档