Reputation: 22947
I have a form that has multiple input fields. I'm applying a bind()
to this form as so:
$("#form-id").bind('keyup change', function(e) {
//Run some other code
alert('here');
});
I would like to determine the ID of which form field triggered the bind event to fire. I've tried working with the Event object sent on the function, however the information doesn't seem to reside there. For example, e.relatedTarget
is null.
Is is possible to determine what child element of the form triggered the bind event to be triggered?
Upvotes: 0
Views: 439
Reputation: 165971
Use the event target
:
$("#form-id").bind('keyup change', function(e) {
var targetId = e.target.id;
});
Here's a working example.
Upvotes: 3
Reputation: 92903
http://api.jquery.com/event.target/ -- event.target
should be what you want.
Upvotes: 2