我一直在尝试很长时间才能使此对话框工作。我爬过谷歌,看看这里的众多问题。无论如何,我无法让它工作形状或形式。我试图得到与此类似的结果: http://example.nemikor.com/basic-usage-of-the-jquery-ui-dialog/为什么不通过我的Javascript对话框工作
我曾尝试使用此源中的代码,但是我无法使其工作。
这是jQuery的:
<script type="text/javascript">
$(document).ready(function(){
// Initialize my dialog
$("#dialog").dialog({
autoOpen: false,
modal: true,
buttons: {
"OK":function() { // do something },
"Cancel": function() { $(this).dialog("close"); }
}
});
// Bind to the click event for my button and execute my function
$("#x-button").click(function(){
Foo.DoSomething();
});
});
var Foo = {
DoSomething: function(){
$("#dialog").dialog("open");
}
}
这是HTML:
<div id="column1">
<h2>
Features</h2>
<p>
Click an image below to view more information on our products.</p>
<img src="../Images/lockIcon.png" alt="Security" />
<input id="x-button" type="button" />
<p id="dialog" display="none">This is content!</p>
</div>
我想尽一切办法得到它的工作,但它没有发生。 jQuery本身就是从这里发布的一个类似问题的答案,我试图在我自己放弃了人生之后使用它,如果你能帮助我,我会非常感激,请注意,我是Javascript /所以请不要在我身上撕裂太糟糕。
谢谢。
什么“不起作用”是什么意思?你有错误吗? – JJJ
对不起,这有点乏味,我的意思是,当我按下按钮时,什么也没有发生,没有功能运行或任何东西。 –
如果这是完整的代码,您尚未关闭第一个“{”。 JavaScript控制台应该会显示语法错误。您可以使用连贯的缩进来避免这些错误。 –