0
for (i = 0; i < array.length; i++) {    
    $("#results").on("click", "#source_" + array[i], function(event) {  
        event.preventDefault();
        alert('i : ' + i); // here i equal table.length, always
     });
}   

Imagine the <div id="results"> has been triggered by a previous javascript action.

If array.lenght = 10, and if I click on <element id="source_5">, the function alerts 10.

How to get the array value of the clicked element, 5 in this example ?

Alexis
  • 1
  • 1
  • what do you mean `value of clicked element`? – renakre Apr 05 '15 at 11:26
  • for (i = 0; i < array.length; i++) { $("#results").on("click", "#source_" + array[i], {num : i}, function(event) { event.preventDefault(); alert('i : ' + event.data.num); }); – Michael Apr 05 '15 at 11:43

0 Answers0