[英]Chrome extension modify selected textbox
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.
我知道如何使用document.getElementById使用Javascript进行操作,但是我不知道如何获取单击的文本框的ID。
thanks 谢谢
You can use document.activeElement
to get the active element. 您可以使用
document.activeElement
获取活动元素。 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. 您将响应
click
事件,并从传递给事件处理程序的事件中获取目标。
Have a read of the quirksmode Introduction to Events . 阅读quirksmode事件简介 。
You might consider using a framework to make dealing with events just a little bit easier . 您可能会考虑使用框架使事件处理变得简单一些 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.