I am creating a Chrome extension and I need to get the id of the selected textbox on the page. I am using Javascript and jQuery
Asked
Active
Viewed 247 times
2
-
Does this answer your question? [How to insert text into selected textbox in JavaScript without ID?](https://stackoverflow.com/questions/43966106/how-to-insert-text-into-selected-textbox-in-javascript-without-id) – samir imtiaz Nov 18 '19 at 15:02
2 Answers
1
You can use the :focus
pseudo-class selector.
for instance:
$("input:focus")
will get the focused input.

Francesco Manicardi
- 770
- 8
- 23
1
Here is how you can get the id
using pure javascript
:-
document.activeElement.getAttribute('id')

Shivratna Kumar
- 1,311
- 1
- 8
- 18