Solved

Jquery - what was the id that triggered the event

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
converting document.write() to innerHTML 7 46
Increase counter and attr inside a while loop 15 34
PHP Web Development 6 21
Getting selected value using Jquery 3 20
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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)
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…

756 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