var info = [
{'user': 'person1','location': "NY"},
{'user': 'person2','location': "NJ"},
{'user': 'person3','location': "NC"}
];
var text="";
for (var i=0; i<=2; i++) {
text+='<div id="box" onclick="alertMe()">'+ info </div>';
}
function alertMe(){
var val = info[location];
alert(val);
}
This is focused on the function alertMe()
part. I'm trying to put each location in one variable so when the user clicks on one, it will show an alert with the specific location.