Skip to content

Instantly share code, notes, and snippets.

@spig
Created October 27, 2018 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spig/ecf49a16e5535800225aaa7727c979aa to your computer and use it in GitHub Desktop.
Save spig/ecf49a16e5535800225aaa7727c979aa to your computer and use it in GitHub Desktop.
Process a table row to get some text information from it
function processRow(row) {
let items = [... row.getElementsByTagName("td")]
let elementName = items[2].innerText
let elementSymbol = items[1].innerText
let atomicNumber = items[0].innerText
return elementName + ", " + elementSymbol + ", " + atomicNumber
}
var elements = [... document.getElementsByTagName("tr")].splice(1,).map(processRow).join('<br/>\n')
document.write(elements)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment