我想将 jquery ui 添加到我的项目中,我已将 jquery-ui.js、jquery.js 和 jquery-ui.css 添加到我的项目中,但想法无法识别 jquery-ui 函数(我的问题是 dialog() 函数)。我认为这是 intellij idea 的问题并运行了我的项目,但不是我想要的。你能告诉我我的代码有什么问题吗?这是我的代码:
$(document).ready(function() { $("#dialog").dialog("open"); });
我想将 jquery ui 添加到我的项目中,我已将 jquery-ui.js、jquery.js 和 jquery-ui.css 添加到我的项目中,但想法无法识别 jquery-ui 函数(我的问题是 dialog() 函数)。我认为这是 intellij idea 的问题并运行了我的项目,但不是我想要的。你能告诉我我的代码有什么问题吗?这是我的代码:
$(document).ready(function() { $("#dialog").dialog("open"); });
在您“打开”对话框之前,您必须“准备”它 - 假设在您的 index.html 中有以下标签:
<div id="msg_dialog" hidden></div>
<div>
<button onclick="showDialog(); return false;">click me!</button>
</div>
那么在你的javascript中你应该有:
function showDialog() {
$('msg_dialog').dialog('open');
}
$(document).ready(function() {
$('#msg_dialog').dialog({
autoOpen: true,
modal: true,
resizable: false,
buttons: {
Dismiss: function () {
$(this).dialog('close');
}
}
});
});
或类似的东西。