# JQuery - Get the ID of a clicked item

**URL:** <https://forum.kirupa.com/t/jquery-get-the-id-of-a-clicked-item/235963>\
**Category:** Uncategorized\
**Created:** [August 16, 2007, 3:21am UTC](https://forum.kirupa.com/t/jquery-get-the-id-of-a-clicked-item/235963 "2007-08-16T03:21:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![denizengt](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@denizengt](https://forum.kirupa.com/u/denizengt)\
**Post date:** [August 16, 2007, 3:21am UTC](https://forum.kirupa.com/t/jquery-get-the-id-of-a-clicked-item/235963/1 "2007-08-16T03:21:19Z")

</div>

Hey there all, I have a list of items with the class click, ie

```auto

<a class = "click" id = "1">Item 1</a>
<a class = "click" id = "2">Item 2</a>
<a class = "click" id = "3">Item 3</a>
<a class = "click" id = "4">Item 4</a>

```

and so on - these items are created dynamically.

Now how can I use jquery to return the ID’s of whatever one I click on?

I’ve tried this, but it doesn’t work

```auto

$(".click").click(function(){
                                   //Get the id of this clicked item
                           
                                  pos = this.attr("id");
                                   goPos(pos);
                                   });

```

---

<div class="post-metadata">

**Author:** ![Ajay\_AJ](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Ajay\_AJ](https://forum.kirupa.com/u/Ajay_AJ)\
**Post date:** [October 15, 2014, 5:45am UTC](https://forum.kirupa.com/t/jquery-get-the-id-of-a-clicked-item/235963/2 "2014-10-15T05:45:57Z")

</div>

[COLOR=#444444][FONT=Roboto]we can achieve this simple task using jquery [/FONT][/COLOR][**event.target**](http://api.jquery.com/event.target/)[COLOR=#444444][FONT=Roboto] event object.  
[http://jquerytutorialwithexamples.com/2014/10/get-id-element-fired-event-using-jquery/](http://jquerytutorialwithexamples.com/2014/10/get-id-element-fired-event-using-jquery/)  
[/FONT][/COLOR]
