so I am looking for a way to modify the content of a textbox that I right-click. I know how to do it with Javascript using document.getElementById but what I do not know how to get is the id of the textbox I clicked.
thanks
You can use document.activeElement
to get the active element. For example:
document.activeElement.value = 'Hello!';
You'll be responding to a click
event and taking the target from the event that's passed to your event handler.
Have a read of the quirksmode Introduction to Events .
You might consider using a framework to make dealing with events just a little bit easier .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.