js 获取table单元格的内容

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <mce:script type="text/javascript"><!-- function getContext() { <script type="text/javascript"> function getContext() { alert(document.getElementById('table1').rows[0].cells[1].innerHTML); //or alert(document.getElementById('table1').rows.item(0).cells.item(1).innerHTML); } // --></mce:script> } </script> </head> <body> <table id="table1" border="0" cellpadding="0" cellspacing="0" width="30%"> <tr> <td>username:</td> <td id="name">username</td> </tr> </table> <input type="button" value="submit" onclick="getContext()" /> </body> </html>

你可能感兴趣的:(java,html,function,table,button,border)