【发布时间】:2023-03-12 14:09:02
【问题描述】:
当在对象函数中使用 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
}
帮助?
【问题讨论】:
标签: javascript jquery object this javascript-objects