I have the following code in jQuery:
$("#input").change(function(){
var input = this;
console.log(input);
});
When there is a change in the input, the element is displayed in the console as html. I have tried to change this into plain JavaScript like this:
var img = document.getElementById('input');
img.addEventListener( 'change' , () => {
var input = this;
console.log(input);
});
The output in the console here is the whole html document, not only the input element. Can someone explain to me why this is happening?
Thank you!