mam to:Dostęp JavaScript klasa zmiennej wewnątrz funkcji klasy
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);
}
}
}
Wewnątrz funkcji onkeyup
chciałbym dostęp select
, ale wiem, że nie jest to możliwe, jak jest. Jaki jest właściwy sposób na zrobienie tego?
spróbuj dodać 'this.search.select = this.select' jako trzecia linia twojej funkcji. – Blazemonger