Question: Getting the ID of the element that fired an event using JQuery

Ads

 
 
 

Share on Google+Share on Google+

samar
Getting the ID of the element that fired an event using JQuery
1 Answer(s)      6 years and 5 months ago
Posted in : JavaScript Questions

Hello sir

I want to know-Is there any way to get the ID of the element that fires the event? Please mention the code with your reply. This will make easy for me to understand the concept.

Thanks in advance

Ads
View Answers

December 11, 2010 at 4:38 PM


Dear friend

In jQuery event.target always refers to the element that triggered the event, where 'event' is the parameter passes to the function.

Use the following snippet in your code :

$(document).ready(function() {
    $("a").click(function(event) {
        alert(event.target.id);
    });
});

Ads









Related Tutorials/Questions & Answers:
Getting the ID of the element that fired an event using JQuery
Getting the ID of the element that fired an event using JQuery  Hello sir I want to know-Is there any way to get the ID of the element that fires... event.target always refers to the element that triggered the event, where 'event
JQuery-event working new element
JQuery-event working new element  I want to know- why not an event(in JQuery) works on my created element through jQuery
Advertisements
Using the jQuery event object
Using the jQuery event object       Using the jQuery event object JQuery... to these standards, this system normalize the event object. jQuery. Event
Bind custom event with an element using 'bind'
Bind custom event with an element using 'bind' In this tutorial, we will discuss about how to bind a user define event with an element using 'bind ' function of jQuery. In this example ,  we are firing an user
Test hidden element using JQuery
Test hidden element using JQuery  Suppose i have an element which i am hiding and showing, using .hide(), .show() or .toggle().How do you test to see... using following code snippet : $(element).is(":visible") Hope this will helpful
Getting the last inserted id using jsp
Getting the last inserted id using jsp  Pls how can i retrieve the last inserted id after submitting a form to mysql using jsp
Position one element relative to other using JQuery.
Position one element relative to other using JQuery.  Hello Sir...: none;" id="menu"> <!-- menu stuff in here --> </div> <div id... showMenu = function(ev) { //get the position of the placeholder element var
JQuery-Disabling element in JQuery.
JQuery-Disabling element in JQuery.   How can we enable/disable an element in JQuery
JQuery-Selecting class or ID
am getting little trouble in selecting an item using class or ID in jQuery?   Given below code selects an element of id name "element1" : $('#element1') Since IDs are unique, so it will select only the element of particular id
JQuery-Selecting class or ID
JQuery-Selecting class or ID  Hi Guys, I am new to JQuery. I am getting little trouble in selecting an item using class or ID in jQuery
Creating, getting, and setting content using jQuery
Creating, getting, and setting content using jQuery... content using jQuery Using jQuery , you can add(create) html content... by using jQuery and also can modify it .For example, you can get
JQuery-confirming exsistance of an element.
JQuery-confirming exsistance of an element.  Hi there, How do I test whether an element exists in jQuery?   You can check existance of an element in jQuery using length property of the jQuery collection
jQuery change event
jQuery change event In this tutorial , we will discuss about 'change' event of jQuery. In given below example ,the change event is fired when there is change in the element (on which event is set).When the second option
jQuery bind event
jQuery bind event In this tutorial, we will discuss about how to bind multiple events with an element using jQuery. In this example, a paragraph binds with multiple events like click, mouseenter mouseleave,  dblclick etc using
jquery href onclick event
jquery href onclick event  jquery href onclick event   $('a').click(function (event) { event.preventDefault(); //here you can also do all sort of things });   <script type="text/javascript
JQuery date change event
JQuery date change event  JQuery date change event I have been designing a date form in HTML and JQuery, wher i need two different date vales start date and end date for any event. I have already writen a function that allows
jQuery blur event
jQuery blur event In this tutorial , we will discuss how to handle blur event of jQuery. In the below example , there are two input field ,when you click... on any other elements in the page ,it shows an alert box .The blur event is sent
The scroll browser event of jQuery
The scroll browser event of jQuery In this tutorial ,we will print message on browser's window scrolling using scroll browser event of jQuery. In this example, some paragraphs are written , when we scroll down, a message
Understanding the jQuery event handling mechanism
Understanding the jQuery event handling mechanism       Understanding the jQuery event handling mechanism First of all , you need to know -What is an event
jQuery focus event
jQuery focus event In this tutorial, we will discuss about how to handle focus event of jQuery. In this example, 2 text field and one password field...()' method of jQuery.   focusEvent.html <!DOCTYPE html>
Selenium webdriver - Getting Xpath for element in IE
Selenium webdriver - Getting Xpath for element in IE   How to get Xpath for element in IE
Selenium webdriver - Getting Xpath for element in IE
Selenium webdriver - Getting Xpath for element in IE   How to get Xpath for element in IE
jQuery 'submit' form event
jQuery 'submit' form event In this tutorial, we will discuss about the  'submit' form event of jQuery. In this example... when "submit" event return 'true' to 'form'
'key down' mouse event of the jQuery
'key down' mouse event of the jQuery In this tutorial ,we will display ASCII value using "key down" method of jQuery. In this example...;/head> <body> <input id="whichkey" value="
jQuery '.live' & '.die' Mouse events
jQuery '.live'  & '.die' Mouse events In this tutorial ,we will discuss about how to  remove an event using 'die' mouse event of jQuery. In this Example, we removes the 'click' event
delete row using id
delete row using id  package pkg2; import org.hibernate.Query; import... = "delete from Insurance insurance where id = 2"; Query query = sess.createQuery...()); } } } this is the code m using . Error is -query must begin with SELECT or FROM
Selecting element using jQuery.
Selecting element using jQuery In this tutorial , we will discuss about... to: Select the element by id Apply the different operations, interceptors, css... element in HTML page and perform the different operations using JavaSript
set the focus on an element using Javascript
set the focus on an element using Javascript  How to set the focus on an element using Javascript
Auto select cell on mouse hover using 'hover' mouse event
Auto select cell on mouse hover using 'hover' mouse event In this tutorial, we will discuss about how to highlight Table's cell on mouse hover using jQuery 'hover' mouse event. In this example, a table is given
Printing Session Id Using Variable
Printing Session Id Using Variable  Hi, I am a learner in PHP language. Could any one guide me, how to print session Id using variable in PHP. Thanks
dynamically created links id from mysql table is not getting
dynamically created links id from mysql table is not getting  guys... to another page, but while i'm trying to access its value, i'm getting only... only getting the last recordset from table malayalamcinema, plz help me, its
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads