I’m trying to create a select input from javascript and bind a function to when a user changes an option. So far I have:
filter.change = function() {
console.log("CHANGED");
}
But nothing happens on selecting something else. What is wrong with this code. Also, how can I get the new selected value in the function ? Something like:
console.log(this.value + "has been selected")
You were close, you need to use
onchange:Of course as Delan said, you should
addEventListener(andattachEvent) whenever possible. Example: