我正在玩一个真正简单的 jQuery 插件“hello world”,但我在使用jQuery Plugin Boilerplate 时遇到了一些麻烦。例如,即使简单且评论很好,我也觉得我错过了一点,例如,无论我使用什么 jQuery 方法,我都会遇到错误。这是我的初始化函数。
Plugin.prototype = {
init: function() {
console.log(this, this.element); // this.element return my element works fine
this.element.on('click', function() { // 'undefined' is not a function :(
alert('whoa');
});
this.element.click(function() { // not working at all :'(
alert('whoa');
});
},
open: function(el, options) {
// some logic
}
};
你能给我一个提示吗?