我想将一些函数和变量实现到mootools的Element成员中。我有这样的事情Mootools Element.prototype error
Element.prototype.currentChild = this.getFirst();
Element.prototype.scrollToNext = function(delta, tag){ .... }
后,我创建一个新的元素和鼠标滚轮事件绑定到跨度和存取权限是currentChild。
body_container = new Element('div', {
events:{
'mousewheel': function(e){
var elem = new Element(this);
elem.currentChild.setStyle('background-color', 'transparent');
elem.scrollToNext(e.wheel);
elem.currentChild.setStyle('background-color', '#C6E2FF');
e.stop();
}
}
});
的问题是,我得到以下错误:
Uncaught TypeError: Object [object Window] has no method 'getFirst'
你知道什么可能会导致这样? LE:是的,我期待'this'是一个元素。但我不明白为什么它会是Window类型。
你有什么期待'this'是在这里:*'Element.prototype.currentChild = this.getFirst();'* – Esailija 2012-07-30 19:18:16
嗯,这显然是一个'Window'对象而不是预期的“元素”。 – TheZ 2012-07-30 19:18:22