document.getElementById('my').onkeypress = function(event) {
this.value = this.value.toUpperCase()
}
<input id='my' type="text">
Can someone explain to me what the this variable points to in the code above? Does it point to the input html element I grabbed from the document.getElementById('my)? Or does it point to the window object in the browser? Also what is the event parameter passed into the anonymous function?
For some reason when I run this code the value of each character is uppercased except the last char. So for example when I enter: a. The character a is not uppercased immediately it is only uppercased when I enter another letter. For example: Ab. Now b is not uppercased until I enter another letter after b: ABc. And this continues on. Can someone please explain why this happen?