0

Just been playing around with js and noticed this.value is undefined in the node to which I've attached a change event listener. Probably missing something obvious but would appreciate an explanation.

HTML

   <label for="spacing">Spacing:</label>
      <input
        id="spacing"
        type="range"
        name="spacing"
        min="10"
        max="200"
        value="10"
        data-sizing="px"
      />

JS

const singleInput = document.getElementById("spacing");

const handleUpdate = (e) => {
        console.log(this.value);
        console.log(e.target.value);
      };

singleInput.addEventListener("change", handleUpdate);

// this.value = undefined, e.target.value = defined

0 Answers0