Answers for "on data change javascript"

5

js select on change value

document.getElementById('my-select').addEventListener('change', function() {
  console.log('You selected: ', this.value);
});
Posted by: Guest on May-14-2020
1

event when variable value changes javascript

var obj = {
  value: '',
  letMeKnow() {
    console.log(`The variable has changed to ${this.testVar}`);
  },
  get testVar() {
    return this.value;
  },
  set testVar(value) {
    this.value = value;
    this.letMeKnow();
  }
}

console.log(obj.testVar)

obj.testVar = 5;
console.log(obj.testVar)

obj.testVar = 15;
console.log(obj.testVar)
Posted by: Guest on July-20-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language