Solved

Jquery - what was the id that triggered the event

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

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
0
Comment
Question by:Pedro Chagas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Expert Comment

by:Randy Poole
ID: 40312862
change your alert to :
alert($(this).id);

Open in new window

to see what you get
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40312874
$("#one, #two").focus(function(){
    alert($(this).attr("id"))
    alert($(this).is(":focus"));
}); 

Open in new window

0
 
LVL 3

Author Comment

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

The best regards, JC
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

737 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