<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin:0px;
padding:0;
}
.active{
border:1px solid red;
width:100px;
height:50px;
}
div{
width:900px;
height:350px;
margin-top: 100px;
margin-left:200px;
}
table,td{
border:1px solid black;
}
td{
width:200px;
height:30px;
}
table{
border-collapse: collapse;
}
</style>
</head>
<body>
<div>
<table id='sheet' >
<thead>
<td>ID</td>
<td>姓名</td>
<td>年龄</td>
</thead>
<tbody>
<tr>
<td>1</td>
<td>张三</td>
<td>21</td>
</tr>
<tr>
<td>2</td>
<td>李四</td>
<td>22</td>
</tr>
<tr>
<td>3</td>
<td>王尔</td>
<td>34</td>
</tr>
</tbody>
</table>
</div>
<script>
window.onload=function(){
//获取表格中张三 的名字
//现获取表格id 然后获取tbody 然后获取第几行第几列
// var sheet=document.getElementById('sheet');
// var td1=sheet.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[0].getElementsByTagName('td')[1];
// alert(td1.innerHTML);
var sheet=document.getElementById('sheet');
var td1=sheet.tBodies[0].rows[0].cells[ 1];
alert(td1.innerHTML);
//获取
//toBodies tHead tFoot rows cells
}
</script>
</body>
</html>