Skip to content

Instantly share code, notes, and snippets.

@hannesgassert
Last active August 29, 2015 14:04
Show Gist options
  • Save hannesgassert/c45bb5fcda342681930c to your computer and use it in GitHub Desktop.
Save hannesgassert/c45bb5fcda342681930c to your computer and use it in GitHub Desktop.
var entries = [],
title, descr, href;
function check() {
var $elt = $(this);
if (this.tagName === 'H2') {
return;
}
if (this.tagName === 'P') {
descr = $elt.text();
return;
}
if (this.tagName === 'UL' || this.tagName === 'LI') {
$elt.children().each(check);
return;
}
if (this.tagName === 'A') {
title = $elt.text();
href = $elt.attr('href');
entries.push([title, href, descr]);
title = null;
href = null;
descr = null;
}
}
$('.article').children().each(check);
console.log(entries);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment