小编Ian*_*thy的帖子

在类函数中访问JavaScript类变量

我有这个:

function FilterSelect(select, search) {
    this.select = select;
    this.search = search;
    // Get the current list options
    this.options = this.select.options;
    // Whenever the text of the search box changes, do this
    this.search.onkeyup = function() {
        // Clear the list
        while(this.select.options.length > 0) {
            this.select.remove(0);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在onkeyup我希望访问的函数内部select,但我知道它不可能存在.这样做的正确方法是什么?

javascript inheritance class

12
推荐指数
1
解决办法
8488
查看次数

标签 统计

class ×1

inheritance ×1

javascript ×1