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 Javascrip开发者_如何学Pythont 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.
精彩评论