Uncaught TypeError: $(…).on is not a function
Uncaught TypeError: $(…).on is not a function
我在我的页面上使用 JQuery UI 对话框并收到此错误
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test</title>
<script src="Scripts/jquery-1.6.4.js"></script>
<script src="Scripts/jquery-ui-1.11.4.js"></script>
<script>
$(document).ready(function () {
$(".hlk1").on("click", function () {
var linkId = $(this).attr("linkID");
alert(linkId);
// initialize dialog
var dlg = $("#dialog").dialog({
autoOpen: false,
modal: true,
draggable: false,
resizable: false,
position: ['center', 'top'],
height: 380,
width: 530,
dialogClass: 'ui-dialog-osx',
buttons: {
"Done": function () {
$(this).dialog("close");
}
}
});
// load content and open dialog
dlg.load('page2.html?id=' + linkId).dialog('open');
});
});
</script>
</head>
<body>
<a href="#" class="hlk1" linkid="305">Click here</a>
<br/>
<a href="#" class="hlk1" linkid="890">Click here</a>
<br/>
<div id="dialog"></div>
</body>
</html>
任何人都可以帮我解决这个问题吗?它可能是 JQuery 版本,但这是通过 NuGet 包管理器
安装的版本 Visual Studio
.on()
是在 jQuery 1.7 中引入的,但看起来你是 运行 1.6.4。如果你不能改变版本,你应该能够改变你的功能 .click
$(".hlk1").click(function () {
...
我在我的页面上使用 JQuery UI 对话框并收到此错误
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test</title>
<script src="Scripts/jquery-1.6.4.js"></script>
<script src="Scripts/jquery-ui-1.11.4.js"></script>
<script>
$(document).ready(function () {
$(".hlk1").on("click", function () {
var linkId = $(this).attr("linkID");
alert(linkId);
// initialize dialog
var dlg = $("#dialog").dialog({
autoOpen: false,
modal: true,
draggable: false,
resizable: false,
position: ['center', 'top'],
height: 380,
width: 530,
dialogClass: 'ui-dialog-osx',
buttons: {
"Done": function () {
$(this).dialog("close");
}
}
});
// load content and open dialog
dlg.load('page2.html?id=' + linkId).dialog('open');
});
});
</script>
</head>
<body>
<a href="#" class="hlk1" linkid="305">Click here</a>
<br/>
<a href="#" class="hlk1" linkid="890">Click here</a>
<br/>
<div id="dialog"></div>
</body>
</html>
任何人都可以帮我解决这个问题吗?它可能是 JQuery 版本,但这是通过 NuGet 包管理器
安装的版本 Visual Studio.on()
是在 jQuery 1.7 中引入的,但看起来你是 运行 1.6.4。如果你不能改变版本,你应该能够改变你的功能 .click
$(".hlk1").click(function () {
...