如何获取焦点文本框的ID?

时间:2019-11-18 14:59:03

标签: javascript jquery html textbox

我正在创建一个Chrome扩展程序,我需要获取页面上所选文本框的ID。 我正在使用Javascript和jQuery

2 个答案:

答案 0 :(得分:1)

您可以使用Document1伪类选择器。 例如: export interface AttachmentForm { name: string; isDuplicate: boolean; } ngOnInit() { this.attachmentForms = [ {name: 'Document1', isDuplicate: false}, {name: 'Document2', isDuplicate: false}, {name: 'Document1', isDuplicate: false}, {name: 'Document3', isDuplicate: false}, ]; this.findDuplicates() ; } findDuplicates() { const newArr: AttachmentForm[] = []; this.attachmentForms.forEach((item, index) => { if (newArr.findIndex(i => i.name === item.name) === -1) { item.isDuplicate = false; } else { item.isDuplicate = true; } newArr.push(item); }); this.attachmentForms = newArr; } 将获得重点关注的输入。

答案 1 :(得分:1)

以下是使用纯Private Sub Form1_Load(ByVal sender As Object, e As EventArgs) Handles MyBase.Load Combobox1.DropDownStyle = ComboBoxStyle.DropDown End Sub Private Sub ComboBox1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown If e.KeyCode = Keys.Enter Then ComboBox1.Items.Add(Combobox1.Text) ComboBox1.SelectedIndex = ComboBox1.Items.Count - 1 End If End Sub 获得id的方法:-

javascript