javascript - Loop through multiple values within an object -
what i'm trying pretty simple. have this:
var looptest = { test1: { date : ['november 2011', 'a new date'] }, test2: { date : 'january 2012' } }; and using for...in so:
for(var key in looptest) { $('.content').append('- '+looptest[key].date+'<br />'); } i want make test1.date values display separate elements. currently, they're 1 string. how go this?
here's fiddle: jsfiddle
keep short , sweet
for (var key in looptest) { [].concat(looptest[key].date).foreach(function(date) { $('.content').append('- ' + date + '<br />'); }); }
Comments
Post a Comment