Monday, September 15, 2008

Table's Attributes

I just happened to know that we can traverse rows columns in table easily with the table's dom method like tBodies, rows and cells, they all are array.

Example

Var tbody = document.getEelementById('myTable').tBodies , will return the array of tBody inside the tablbe.

Var tableRows = tbody.rows, will return the array of row inside tbody.

Var tableCells = tableRows.cells, will return the array of cells inside tableRows.

From that, you can traverse all the elements inside the table, and one of application that people are using now is sorting the row of a table. You may find it in 'Professional Javascript for Web Developer ' by Nicholas C.zakas.



No comments: