Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
因此,我有这张表,其中每个产品旁边都有文本字段,我将通过数字键盘(0-9 的按钮)在任何选定的文本字段中输入值。我需要知道如何获取当前选定文本字段的 id 值,并使用数字键盘将数字作为文本添加到其中。
您需要使用this.id来获取ID特定元素的。例如,当我完成一个片段时,一旦你按下Enter键就会说 ID。
this.id
ID
<input id="this-is-id" onkeyup="if (event.keyCode == 13) alert(this.id);" />