Solved

Jquery - what was the id that triggered the event

Posted on 2014-09-09
3
171 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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 implement server side field validation and display customized error messages to the client.
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…

729 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