2010-10-12 31 views
0

我一直想弄清楚如何让jquery对话框工作。对于我的生活,我无法实现它的工作。下面是一些HTML与在线的JavaScript我写:为什么不是我的jquery对话框工作?

<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中的按钮,它说Object doesn't support this property of method.我在做什么错?

回答

3

据我所知,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托管版本的源代码。

我会想象,谷歌托管的版本包含了很多东西,你不需要,所以你可能能够通过downloading your own copy,只选择您需要的组件,以加快加载时间。

+0

接受:这是正确的,我不知道的jQuery和jQuery UI是两个不同的脚本库。谢谢! – 2010-10-12 15:48:15

0

,你可以尝试使用这个打开,

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

或关闭

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