Im storing a little data in my jQuery. I want to call it from arrays with functions, but when I call the array it doesn't return any value. There's my JSFiddle
jQuery code
$('button').click(showInfo);
function showInfo(){
var data = $(this).attr("dataid");
//alert(data);
dataArray(data);
writeData(data);
}
function dataArray(call){
var person1 = [{
'name':'First Name',
'position':'Director'
}];
var person1 = [{
'name':'Second Name',
'position':'Director'
}];
}
function writeData(called){
$('.person').removeClass('hidden');
dataArray(called[0]);
// write in divs
$('.person .name').text(dataArray(called['name']));
$('.person .position').text(dataArray(called['position']));
}
var person2as the second variable, instead of 2var person1linesreturnsomething. Maybe you should just explain what you want to happen, because this code does not really reveal that.