Skip to content

Instantly share code, notes, and snippets.

@jaamaalxyz
Created June 1, 2019 08:34
Show Gist options
  • Save jaamaalxyz/3e095812dbb8c54285077e6dc45ec826 to your computer and use it in GitHub Desktop.
Save jaamaalxyz/3e095812dbb8c54285077e6dc45ec826 to your computer and use it in GitHub Desktop.
function extractData() {
const boxes = Array.from(document.querySelector('#boxes').children);
const result = boxes.map(box => {
const obj = {
title: '',
subtitle: ''
}
for(let item of Array.from(box.children)) {
if(item.className === 'title') {
obj.title = item.textContent;
}
if(item.className === 'subtitle') {
obj.subtitle = item.textContent;
}
}
return obj;
});
return result;
}
extractData()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment