Created
January 30, 2011 22:10
-
-
Save matagus/803313 to your computer and use it in GitHub Desktop.
jQuery table to Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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