Reputation: 25
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
Upvotes: 2
Views: 512
Reputation: 1311
Here is how you can get the id
using pure javascript
:-
document.activeElement.getAttribute('id')
Upvotes: 1
Reputation: 809
You can use the :focus
pseudo-class selector.
for instance:
$("input:focus")
will get the focused input.
Upvotes: 1