简体   繁体   English

为什么我的jquery对话框不起作用?

[英]Why isn't my jquery dialog box working?

I've been trying to figure out how to get a jquery dialog box to work. 我一直在试图弄清楚如何使一个jquery对话框起作用。 For the life of me, I can't get it to work. 为了我的一生,我无法使它运转。 Here is some html with in-line javascript I've written: 这是一些我编写的带有嵌入式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>

When I click the button in Internet Explorer, it says Object doesn't support this property of method. 当我单击Internet Explorer中的按钮时,它说“ Object doesn't support this property of method. What am I doing wrong? 我究竟做错了什么?

As far as I know, the dialog() function is part of jQuery UI, and it doesn't look like your code references the UI library. 据我所知,dialog()函数是jQuery UI的一部分,它看起来不像您的代码引用了UI库。 Try adding something like 尝试添加类似

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

in the <head> below where you reference the jQuery library. 在下面引用jQuery库的<head>中。 This will pull in the Google-hosted version of the source. 这将提取由Google托管的源代码版本。

I would imagine that the Google-hosted version includes lots of things you don't need, so you might be able to speed up loading times by downloading your own copy and only selecting the components that you need. 我可以想象Google托管的版本包含许多您不需要的东西,因此您可以通过下载自己的副本并仅选择所需的组件来加快加载时间。

you can try to use this to open, 您可以尝试使用它打开,

 function showDialog() {  
        jq('#dialogBox').dialog('open');  
    } 

or to close 或关闭

    function showDialog() {  
        jq('#dialogBox').dialog('close');  
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM