在对象函数中使用 jQuery 方法(即 - .each())时,“this”变量将引用被迭代的对象。没有“this”如何访问对象的功能?我意识到这有点令人困惑,所以:
test.prototype.init = function(node) {
node.children().each(function() {
//call test.anotherFunction() here
//Would normally call this.anotherFunction(),
// but "this" refers to the current child.
});
}
test.prototype.anotherFunction = function() {
//whatever
}
帮助?