Skip to content

Instantly share code, notes, and snippets.

@matagus
Created January 30, 2011 22:10
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 matagus/803313 to your computer and use it in GitHub Desktop.
Save matagus/803313 to your computer and use it in GitHub Desktop.
jQuery table to Array
var data = (function () {
var _data = [];
$("#<TABLE-ID-REPLACE-ME> tbody td").each(
function () {
var rowIndex = this.parentNode.rowIndex -1,
cellValue = this.innerHTML.trim();
if (_data[rowIndex]) {
_data[rowIndex].push(cellValue);
} else {
_data[rowIndex] = [cellValue];
}
}
);
return _data;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment