1. Realize the source code
<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "> <HTMLxmlns= "http://www.w3.org/1999/xhtml"> <Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <title>JavaScript implementation gets the value of a column in a table</title> <Scripttype= "Text/javascript"> functionGettdvalue () {vartableId=document.getElementById ("Tab"); varStr= ""; for(varI=1; I<Tableid.rows.length;i++) {alert (tableid.rows[i].cells[1].innerhtml); }}</Script> </Head> <Bodystyle= "width:100%; height:100%;"> <Tablestyle= "width:100%; height:100%;"ID= "tab"onclick= "Gettdvalue ()"Border= "1"cellpadding= "1"cellspacing= "1"> <TRstyle= "Background-color: #CCC;"> <th>School Number</th> <th>Name</th> <th>Gender</th> <th>Age</th> </TR> <TR> <TD>1</TD> <TD>Reese</TD> <TD>Man</TD> <TD>22</TD> </TR> <TR> <TD>2</TD> <TD>Wang Qian</TD> <TD>Woman</TD> <TD>20</TD> </TR> <TR> <TD>3</TD> <TD>Yu Qian</TD> <TD>Man</TD> <TD>18</TD> </TR> <TR> <TD>4</TD> <TD>Liu Lang</TD> <TD>Woman</TD> <TD>19</TD> </TR> <TR> <TD>5</TD> <TD>Zhuge liang</TD> <TD>Man</TD> <TD>20</TD> </TR> <TR> <TD>6</TD> <TD>Dongfangyun</TD> <TD>Woman</TD> <TD>21st</TD> </TR> <TR> <TD>7</TD> <TD>Gongsunze</TD> <TD>Man</TD> <TD>22</TD> </TR> <TR> <TD>8</TD> <TD>Baoqing</TD> <TD>Woman</TD> <TD>23</TD> </TR> <TR> <TD>9</TD> <TD>Intellectual</TD> <TD>Man</TD> <TD>20</TD> </TR> <TR> <TD>10</TD> <TD>Liusi Silk</TD> <TD>Woman</TD> <TD>21st</TD> </TR> </Table> </Body> </HTML>
How JavaScript gets the value of a column in a table