# Recognizing the calling object

**URL:** <https://forum.kirupa.com/t/recognizing-the-calling-object/636473>\
**Category:** Uncategorized\
**Created:** [April 21, 2017, 2:56am UTC](https://forum.kirupa.com/t/recognizing-the-calling-object/636473 "2017-04-21T02:56:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luis\_vera](https://avatars.discourse-cdn.com/v4/letter/l/9fc29f/32.png) [@luis\_vera](https://forum.kirupa.com/u/luis_vera)\
**Post date:** [April 21, 2017, 2:56am UTC](https://forum.kirupa.com/t/recognizing-the-calling-object/636473/1 "2017-04-21T02:56:14Z")

</div>

Hi, I have an array of images obtained in this way:  
"var pictures = document.getElementsByTagName(“img”).  
Besides, I have a function associated with each one of them called by “onclick”, but I must know the index of calling image inside the function

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [April 21, 2017, 11:05am UTC](https://forum.kirupa.com/t/recognizing-the-calling-object/636473/2 "2017-04-21T11:05:23Z")

</div>

Assuming pictures is in scope, it should be as simple as

```auto
var index = pictures.indexOf(this);

```
