javascript - 为什么我的 jquery 对话框不工作?

标签 javascript jquery modal-dialog

我一直在试图弄清楚如何让 jquery 对话框工作。对于我的一生,我无法让它发挥作用。这是我编写的一些带有内联 JavaScript 的 html:

<html>  
<head>  
    <script type="text/javascript" src="jquery.js"></script>  
    <script type="text/javascript">  
        function showDialog() {  
            $('#dialogBox').dialog();  
        }  
    </script>  
</head>  
<body>  

<input type="button" value="Click me" onclick="showDialog();" />

<div id="dialogBox">
    <p>This is the text of my dialog box.</p>
</div>

</body>
</html>

当我单击 Internet Explorer 中的按钮时,它显示对象不支持方法的此属性。我做错了什么?

最佳答案

据我所知,dialog()函数是jQuery UI的一部分,它看起来不像你的代码引用了UI库。尝试添加类似

的内容
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/jquery-ui.min.js" type="text/javascript"></script>

<head>下面引用了 jQuery 库。这将引入 Google 托管的源版本。

我认为 Google 托管的版本包含许多您不需要的内容,因此您也许可以通过 downloading your own copy 加快加载时间并且仅选择您需要的组件。

关于javascript - 为什么我的 jquery 对话框不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3916107/

相关文章:

javascript - jquery.js 是否缓存在浏览器中?

javascript - 防止标签点击页面跳转JS

c++ - 如何在 Mac 上用 C++ 显示模态消息框?

javascript - 谷歌地图模式问题

javascript - 如何使用jquery从输入字段模态 Bootstrap 获取值并将值显示到同一模态中的另一个输入字段?

javascript - 如何在html中的javascript中显示内部图像

javascript - 如何在 php 中单击按钮显示表格?

javascript - 在 jQuery 中从 asp.net runat 服务器获取 ID

javascript - 使用 dynatable 查询样式化列表

javascript - 将 L.BeautifyMarkers 与 L.MarkerClusters 一起使用