1:遍歷並輸出表
<表ID =“ tb”> <tr> <td> </td> </tr> <tr> <td> <td> </td> </td> </tr> </table> function f(){var t = document.getElementById(“ tb”)。 childnodes.item.item.item(0) j = 0; j <t.childnodes(i).childnodes.length; j ++){alert(t.childnodes(i).childnodes(j).innertext);}}}}}}2:遍歷表,讀取複選框狀態和其他列值
<! doctype html public' - // w3c // dtd xhtml 1.0 transitional // en'“” http://www.org/tr/xhtml1/dtd/xhtml1/xhtml1-xhtml1-transitional.dtransitional.dtd xmlns =“ http://www.w3.org/1999/xhtml”> <head> <head> <title> <title> niTitled Page </title> </head> <hody onload =“ f() i = 0; i <t.childnodes.length; i ++){arter(t.childnodes(i).firstchild.firstchild.firstchild.nodevalue); alert(t.ChildNodes(i).ChildNodes .ChildNodes [1] .firstchild.checked); }} </script> <table ID =“ tb”> <tr> <td> 1234 </td> <td> <td> <input type =“ checkbox”/> </> </> </> </td> <td> </td> </td> </tr> <tr> <tr> <ttd> 2234 </td> 2234 </td> <td> <td> <td> <td> <tp> <tp> <tput> <tput> <輸入/> </td> <td> </td> </tr> <tr> <td> 3234 </td> <td> <td> <input type =“ checkbox”/> </> </> </td> <td> </td> </td> </td> </tr> </tr> </table> </table> </table> </table> </tobod> </hody> </html> </html>