Created
April 10, 2014 16:35
-
-
Save anonymous/10400178 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 heads = ['NAME', 'AGE', 'GENER']; | |
var rows = [['TOM', 21, 'MALE'],['LUCY', 16, 'FEMALE'],['JERRY', 23, 'MALE']]; | |
// '<table><thead><tr>'+ | |
// 在这里循环 head | |
// for head in heads: | |
// <th>head</th> | |
// '</tr></thead><tbody>'+ | |
// 在这里循环 rows | |
// for row in rows: | |
// <tr> | |
// 这里循环 row 里面的单元格 | |
// for cell in row: | |
// <td>cell</td> | |
// </tr> | |
// '</tbody></table>'; | |
var html = '<table><thead><tr>'; | |
for (var i = 0; i < heads.length; i++) | |
html += '<th>'+heads[i]+'</th>'; | |
html += '</tr></thead><tbody>'; | |
for (i = 0; i < rows.length; i++) { | |
html += '<tr>'; | |
for (var j = 0; j < rows[i].length; j++) | |
html += '<td>'+ rows[i][j] +'</td>'; | |
html += '</tr>'; | |
} | |
html += '</tbody></table>'; | |
console.log(html); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment