<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta charset="UTF-8">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<table id='mytable'>
<tbody>
<tr>
<td id='mytd'>这里是td的值</td>
</tr>
</tbody>
</table>
<br />
<input type='button' value='绝对路径获取td的值' οnclick='getTdDirectly()' />
<input type='button' value='相对路径获取td的值' οnclick='getTdIndirectly()' />
<script >
function getTdDirectly(){
var tdobj = document.getElementById('mytd');
alert(tdobj.innerText);
}
function getTdIndirectly(){
var tbobj = document.getElementById('mytable');
alert(tbobj.rows[0].cells[0].innerHTML);
//或tbobj.rows[0].cells[0].innerText
}$(function(){
});
</script>
</body>
</html>