扩展$ .fn.init函数 [英] Extending $.fn.init function
本文介绍了扩展$ .fn.init函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下内容扩展jQuery:
I'm trying to extend jQuery with the following:
$.fn.extend({
initCore: $.fn.init,
init: function (selector, context, rootjQuery) {
return $.fn.initCore(selector, context, rootjQuery);
}
}),
但是,它似乎工作不正常,并且创建简单的操作(例如点击警告)会产生错误.有人可以发现问题吗?
However, it doesn't seem to work right, and creating simple things such as an alert on click produce errors. Can anyone spot the problem?
提前谢谢!
推荐答案
$.fn.init
是类构造函数本身.
尝试添加$.fn.init.prototype = $.fn
后记以恢复原始原型.
Try adding $.fn.init.prototype = $.fn
afterwords to restore the original prototype.
这篇关于扩展$ .fn.init函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文