我在我的项目中编写了这段代码,它显示错误:
Uncaught TypeError: Cannot read property 'apply' of undefined
if (TempData["notice"] != null)
{
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" type="text/css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p id="dialog" style="color:red">
@TempData["notice"]<br />
<button id="bclose">Ok</button>
</p>
<script language="javascript">
$('#dialog').dialog({
dialogClass: "no-close",
buttons: [{
text: "Ok",
Click: function() {
$('#dialog').dialog('close');
}
}]
});
</script>
}
我需要为上述代码添加任何库吗
最佳答案
将您的脚本部分放入:
$(document).ready(function(){
//your script here
});
类似这样的事情:
<script language="javascript">
$(document).ready(function(){
$('#dialog').dialog({
dialogClass: "no-close",
buttons: [{
text: "Ok",
click: function() {
$('#dialog').dialog('close');
}
}]
});
});
</script>
这里正在工作 jsfiddle
关于javascript - jquery-ui.js :12443 Uncaught TypeError: Cannot read property 'apply' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40607033/