开发者

Chrome extension modify selected textbox

开发者 https://www.devze.com 2023-02-04 13:30 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消