日期:2014-05-16 浏览次数:20316 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<table id="table1">
<tr>
<td>01</td>
<td>02</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
</table>
<input type="button" id="btn" value="findMe" />
<script type="text/javascript">
document.getElementById('btn').onclick=function(){
var tab=document.getElementById('table1');
var rows=tab.getElementsByTagName('tr');
var cols=rows[1].getElementsByTagName('td');
alert(cols[1].innerHTML);
};
</script>
</body>
</html>
document.getElementById('btn').onclick=function(){
var tab=document.getElementById('table1');
alert(tab.rows[1].cells[1].firstChild.data);
};