I have an array. I am getting data from Array and using it in jQuery Append to list. But when I am clicking on list item its only showing the last element.
var a
You have to move the event outside for loop
var array = [[1,2,7],[3,4,8],[5,6,9]];
for (var i = 0; i < array.length; i++){
var firstVal = array[i].[0];
var secondVal = array[i].[1];
var thirdVal = array[i].[2];
var list = ""+ firstVal +""
+ ""+ secondVal +"
";
$("#myDiv").append(list);
}
$(document).on('click','.divClass', function(){
alert(thirdVal);
})