Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

using the for of loop in pure javascript to populate data into HTML

// blah blah blah ajax call blah blah blah fetch, blah blah blah something else that brings me data

//data comes back as something to iter through
var data = [{
  email: 'something'
}, {
  email: 'something2'
}, {
  email: 'blah'
}, {
  email: 'blah2'
}, {
  email: 'blah blah'
}, {
  email: ':o blah'
}]


data.forEach(item => {
  var div = document.createElement('div')
  div.innerHTML = `<div>some fancy box////   ${item.email}   \some more facy box</div>`

  document.body.appendChild(div);
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #loop #pure #javascript #populate #data #HTML
ADD COMMENT
Topic
Name
1+6 =