# Question about the Content Slider you wrote in Animations

**URL:** https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245
**Category:** web dev
**Created:** [February 14, 2016, 6:51pm UTC](https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245 "2016-02-14T18:51:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bstagy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bstagy/32/7351_2.png) [@bstagy](https://forum.kirupa.com/u/bstagy)
#### Post date: [February 14, 2016, 6:51pm UTC](https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245/1 "2016-02-14T18:51:49Z")

</div>

The content slider you created is just brilliant! There is a question I have about the setClickedItem() fx. You’re adding “e” as a parameter, yet when you call the function in the click event listener, no arguments are being passed in parenthesis.  
I’m missing something here…Since link.itemID = i; Does that value of i get satisfied as an argument because the activeLink within setClickedItem() is referencing the value of itemID…which is being dynamically set in the event listeners for loop?

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [February 15, 2016, 5:22am UTC](https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245/2 "2016-02-15T05:22:29Z")

</div>

Hi, bstagy!  
When specifying an event handler via the addEventHandler function, you don’t have to specify an argument. The `setClickedItem` event handler gets the `e` argument populated automatically 🙂

The value of `i` is less an argument and more of a value that happens to be set on the `itemID` property. Even if nothing gets clicked, the `for` loop (like you mention) sets the `itemID` property to whatever number `i` is at that time. Think of `itemID` as a permanent addition to our link elements as accessed by: `var links = document.querySelectorAll(".itemLinks");`

Does that help answer your question?

Cheers,  
Kirupa

---

<div class="post-metadata">

### Author: ![bstagy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bstagy/32/7351_2.png) [@bstagy](https://forum.kirupa.com/u/bstagy)
#### Post date: [February 15, 2016, 2:21pm UTC](https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245/3 "2016-02-15T14:21:09Z")

</div>

Hi Kirupa!  
It does for the most part. There are so many little intricacies to JS.  
I’m still a bit confused on where the argument gets it’s value from because in your code you have clickedLink = e.target; I’m assuming the **e** get’s it’s value on the element it’s clicked on, but what if it’s say a ‘scroll’ event or something else? I suppose there are only certain instances when you can pass an argument to a function being called in Eventlisteners.

Best,  
bstagy

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [February 16, 2016, 5:38am UTC](https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245/4 "2016-02-16T05:38:22Z")

</div>

Very close! The `e` is actually the event argument, and every event will pass that event argument object on.

For something mouse related, a `MouseEvent` object is returned. For a scroll, a `ScrollEvent` object is returned. Depending on the type of event you are dealing with, the properties that event’s object returns will be different. For example, a `MouseEvent` object has ways for you to figure out which mouse button was clicked. The `target` property tells you which element the mouse event was sent from. A `ScrollEvent` object would tell you things related to the scrolling.

🙂

---

<div class="post-metadata">

### Author: ![bstagy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bstagy/32/7351_2.png) [@bstagy](https://forum.kirupa.com/u/bstagy)
#### Post date: [February 16, 2016, 2:32pm UTC](https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245/5 "2016-02-16T14:32:51Z")

</div>

Kirupa,  
Thank you for taking the time to explain. It’s still not exactly clear which is why I think it’s one of those things I just have to play with to better understand. Kind of like ‘this’ . 😉

Brad

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [February 18, 2016, 4:05am UTC](https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245/6 "2016-02-18T04:05:41Z")

</div>

No worries! In case this helps, check out the KeyboardEvent and how you can access its properties here: [https://www.kirupa.com/html5/keyboard\_events\_in\_javascript.htm](https://www.kirupa.com/html5/keyboard_events_in_javascript.htm) That may help provide more details for my earlier answer 😛

---

<div class="post-metadata">

### Author: ![bstagy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bstagy/32/7351_2.png) [@bstagy](https://forum.kirupa.com/u/bstagy)
#### Post date: [February 19, 2016, 1:59am UTC](https://forum.kirupa.com/t/question-about-the-content-slider-you-wrote-in-animations/634245/7 "2016-02-19T01:59:21Z")

</div>

Awesome thank you Kirupa! I’ll check it out. 🙂
