<!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>
<style type="text/css">
div{
width:500px;
height:300px;
background-color:#F69;
}
</style>
<script language="javascript" type="text/javascript">
function addNines(){
var table=document.createElement("table");
table.setAttribute("border","1px");
for(var i=1;i<=9;i++){
var tr=document.createElement("tr");
for(var j=1;j<=i;j++){
var text=document.createTextNode(i+"*"+j+"="+i*j);
var td=document.createElement("td");
td.appendChild(text);
tr.appendChild(td);
}
table.appendChild(tr);
}
document.getElementById("d1").appendChild(table);
}
function delNines(){
var tr=document.getElementsByTagName("tr");
var table=tr[0].parentNode;
table.removeChild(tr[tr.length-1]);
}
</script>
</head>
<body>
<div id="d1"></div>
<input type="button" value="实现添加九九乘法!" οnclick="addNines()">
<input type="button" value="给我删除一行!" οnclick="delNines()">
</body>
</html>