This is the code i have. I want to have my global variable store and update (with events) the value of a range slider. As you can see, i declared a global variable 'valueA' and changed it inside the function 'on' via jQuery. It's important to note that this.value is NOT undefined and it changes its value every event, as intended. But when I console log valueA after the function that should change it, it returns 0, as if nothing was changed.
var valueA = 0;
var value = $('#myRange');
value.on('input', function(){
valueA = this.value;
});
console.log(valueA)