当我试图在动态加载的元素上触发点击事件时,我在jQuery 1.8中不断收到错误“Object# on’on’

我正在使用jQuery 1.8,并且在使用.on()函数时在某些页面上出现此错误。 其他页面,似乎做同样的事情 – 将触发器附加到动态创建的元素,我使用不会生成此错误:

Uncaught TypeError: Object # has no method 'on' 

JS:

 $(document).ready(function(){ $(document).on("click","button.pagebutton",function() { $("div#pagesforreview").hide(); jsD=Date(); jsP=$(this).html(); $("div#externpage").load("prexternpage.php",{d:jsD,p:jsP},function() { $("div#externpage").show(); $("div#pageactions").show(); jsNc=1; $("div#pagecomments").load("praddcomment.php",{d:jsD,nc:jsNc},function() { $("div#pagecomments").show(); }); }); }); }); 

所有动态生成的“页面按钮”按钮都不会触发。 并且出现错误。 如果我使用不推荐使用的.live()方法,则没有问题。 但是如果可能的话,我更喜欢使用适当的新1.8非弃用方法?

我发现我的头文件是从我的生产服务器而不是我的开发服务器(v.1.8)加载jquery库(v.1.6)…因此产生了问题。 D’哦。 感谢您的评论。

相反,这个$(document).ready(function(){在第一行写这个: jQuery(document).ready(function($){它对我jQuery(document).ready(function($){