Reputation: 435
In my form I have several textboxes like txtItemCode1
, txtItemCode2
, etc.
I use this code to perform some action if I press enter on any of these, but I want to get the selected textbox id. How can I do that?
Upvotes: 4
Views: 17042
Reputation: 10258
variable id should have what you are looking for.
$('input[type="text"]').change(function(){
var id = $(this).attr('id');
});
Upvotes: 10
Reputation: 4520
In the event that you have bound to your textbox's to perform actions on enter, use this to get the id
of the textbox you pressed enter on.
$(this).attr('id')
or
this.id
Upvotes: 1