Loop through an array and Update html elements from array of objects on next()
Hi guys. I need some help on jquery and an array of objects. myArray = [{eventName : "Some text", eventYear : "", eventAge : 21, eventDescription : "", eventPlace : "", eventImage : "", eventAdditionalInfo : "", }, {eventName : "Marriage Text", eventYear : "", eventAge : 23, eventDescription : "", eventPlace : "", eventImage : "", eventAdditionalInfo : "", }, {eventName : "Other text", eventYear : "", eventAge : 24, eventDescription : "", eventPlace : "Some place", eventImage : "", eventAdditionalInfo : "", }, {eventName : "Some more text", eventYear : "1999", eventAge : 25, eventDescription : "", eventPlace : "", eventImage : "src url", eventAdditionalInfo : "", } ] // change some bunch of elements on the DOM using ID mapping them to keys in the objects. function next(){ for ( var i = 0, len = timeLine.length; i < len; i++ ){ document.getElementById('cardTitle').innerHTML = timeLine[i][0].length // probably document.getElementById('cardText').innerHTML = timeLine document.getElementById('cardImage').innerHTML = timeLine } function back(){ for ( var i = 0, len = timeLine.length; i < len; i-- ){ document.getElementById('cardTitle').innerHTML = timeLine document.getElementById('cardText').innerHTML = timeLine document.getElementById('cardImage').innerHTML = timeLine }