我试图在jQuery中添加一个新方法,这样我就可以做一些类似$('#id').MyOwnFunc()的事情了。我的困惑来自于不同的站点和堆栈溢出,我可以看到我可以使用以下任何一种方法:
// #1
jQuery.fn.MyOwnFunc = function() {
var o = $(this[0]) // It's your element
return this; // This is needed so others can keep chaining off of this
};
// #2
jQuery.fn.extend({
My