未捕获的TypeError:$(…).on不是函数

编程入门 行业动态 更新时间:2024-10-28 12:16:49
本文介绍了未捕获的TypeError:$(…).on不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在页面上使用JQuery UI对话框并出现此错误

I am using JQuery UI dialog on my page and getting this error

<!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版本

Can anyone help me figure that one out? It might be the JQuery version but this is the version Visual Studio installed through NuGet package manager

推荐答案

.on() 在jQuery 1.7中,但看起来您正在运行1.6.4.如果您无法更改版本,则只需将功能更改为.click

$(".hlk1").click(function () { ...

更多推荐

未捕获的TypeError:$(…).on不是函数

本文发布于:2023-11-23 03:42:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619957.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   TypeError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!