I have 4 textboxes and a submit button in my web page. Suppose the user enters data in 2 fields and then clicks the submit button. I now want to know in which textbox the cursor was located just before the submit button was clicked.
Any idea on how to do this in Javascript?
You're looking for document.activeElement
, which returns the currently focused element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With