<html>
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">
function showTable(id){
var tb=document.getElementById(id);
var rows=tb.rows;
var d = document.getElementById("mydiv");
alert('divarea=' + d.width * d.height);
for(var i=0;i<rows.length;i++){
var cells=rows[i].cells;
for(var j=0;j<cells.length;j++){
var cell = cells[j];
alert('width= ' + cell.width + ' height= ' + cell.height + ' area =' + cell.width * cell.height);
}
}
}
</SCRIPT>
</head>
<body>
<input type="button" οnclick="showTable('mailTable');" value="遍历table"/>
<div id="mydiv" width="150" height="100">
<table border="1" width="20%" id="mailTable">
<tr>
<td width="20" height="30" colspan="1">列12</td>
<td width="20" height="30">列12</td>
</tr>
<tr>
<td width="40" height="35">列22</td>
<td width="20" height="30">列12</td>
</tr>
<tr>
<td width="15" height="25">列11</td>
<td width="20" height="30">列12</td>
</tr>
<tr>
<td width="48" height="55">列21</td>
<td width="20" height="30">列12</td>
</tr>
</table>
</div>
</body>
</html>
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">
function showTable(id){
var tb=document.getElementById(id);
var rows=tb.rows;
var d = document.getElementById("mydiv");
alert('divarea=' + d.width * d.height);
for(var i=0;i<rows.length;i++){
var cells=rows[i].cells;
for(var j=0;j<cells.length;j++){
var cell = cells[j];
alert('width= ' + cell.width + ' height= ' + cell.height + ' area =' + cell.width * cell.height);
}
}
}
</SCRIPT>
</head>
<body>
<input type="button" οnclick="showTable('mailTable');" value="遍历table"/>
<div id="mydiv" width="150" height="100">
<table border="1" width="20%" id="mailTable">
<tr>
<td width="20" height="30" colspan="1">列12</td>
<td width="20" height="30">列12</td>
</tr>
<tr>
<td width="40" height="35">列22</td>
<td width="20" height="30">列12</td>
</tr>
<tr>
<td width="15" height="25">列11</td>
<td width="20" height="30">列12</td>
</tr>
<tr>
<td width="48" height="55">列21</td>
<td width="20" height="30">列12</td>
</tr>
</table>
</div>
</body>
</html>