Jquery - what was the id that triggered the event

Posted on 2014-09-09
Last Modified: 2014-09-09
Hi E's,
I have this code:
$("#one, #two").focus(function(){

Open in new window

And I have to know what was the id that triggered the event.
The output of this code is false!
How I know if it is the #one or the #two id that triggered the event?

The best regards, JC
Question by:Pedro Chagas
LVL 21

Expert Comment

by:Randy Poole
ID: 40312862
change your alert to :

Open in new window

to see what you get
LVL 58

Accepted Solution

Gary earned 500 total points
ID: 40312874
$("#one, #two").focus(function(){

Open in new window


Author Comment

by:Pedro Chagas
ID: 40313285
Hi Randy, the output is "undefined".
Thanks for trying to help.

The best regards, JC

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now