0

Here's my fiddle https://jsfiddle.net/8u4rgz8v/

Expected result: when I click on the site name it alerts its number e.g. Site1 alerts 1

I encapsulated the call to the onClickSite function with a function as you can see but it doesn't work.

I also tried encapsulating the body of the onClickSite function in a return function(){} but it didn't even alert.

Nani
  • 317
  • 5
  • 15
  • https://jsfiddle.net/arunpjohny/fyw1a2de/ – Arun P Johny Jul 09 '15 at 10:28
  • Why does nobody use SO snippets? All those fiddlers... Anyhow, what do your function do - please explain what this is trying to do. When I click the button, _whats suppossed to happen_? Because right now, it seems like a scary thing is shouting at me. – somethinghere Jul 09 '15 at 10:28
  • Thanks Arun for the fiddle works fine. but why did i have to create a new function? I have tried encapsulating the body of `onClickSite` in a return function and i don't see the difference between what you suggested and that – Nani Jul 09 '15 at 10:31
  • @somethinghere I was actually didn't find it :( i tried for a minute to see where it is but in vain – Nani Jul 09 '15 at 10:32
  • @Nani see the question that is marked as duplicate to see why – Arun P Johny Jul 09 '15 at 10:36
  • @Nani another simple way to do it using html 5 dataset - https://jsfiddle.net/arunpjohny/fyw1a2de/3/ – Arun P Johny Jul 09 '15 at 10:37
  • Okay, thanks for the link, i'll stick to your first solution :) have a good day – Nani Jul 09 '15 at 10:43

0 Answers0