This is my code :
var myinp = document.querySelector(".myinp");
var store = document.querySelector(".store");
myinp.addEventListener("input", function() {update(store);}, false);
function update(elem) {
console.log('Executed');
elem.style.left= this.value + "%";
if(this.value>0) {
elem.textContent= this.value;
} else {
elem.textContent= null;
}
}
The console just shows one Executed
and even then the textContent
does not change.
EDIT
This version of code works:
myinp.addEventListener("input", update, false);
function update() {
thumb.style.left= this.value + "%";
if(this.value>0) {
thumb.textContent= this.value;
} else {
thumb.textContent= null;
}
}
When I am not passing any parameters why does this
refer to the element and not window just like in first case?.