Copy Code code as follows:
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>JavaScript</title>
<body>
<script language= "JavaScript" >
var n = 0;
function showtable (len) {
WI (' <table border= "1" width= "style=" Border-collapse:collapse "><tbody id=" table ">");
for (i=0;i<len;i++) {
if (parseint (i%2) ==1) {
BG = ' #F4FAC7 ';
} else {
BG = ' white ';
}
WI (' <tr bgcolor= ' +bg+ ' ><td> ' + (i+1) + ' line </td></tr> ');
}
WI (' </tbody></table><br/> ');
WI (' <input type= "button" value= "Add" id= "Add"/> ");
}
Function wi (str) {
return document.write (str);
}
Showtable (10);
var add = document.getElementById ("add");
Add.onclick = function () {
n = n+1;
if (n%2==0) {
BG = ' #F4FAC7 ';
} else {
BG = ' white ';
}
var table = document.getElementById ("table");
var tr = document.createelement ("tr");
Tr.bgcolor = BG;
var td = Document.createelement ("TD");
td.innerhtml = ' first ' + (10+n) + ' line ';
Tr.appendchild (TD);
Table.appendchild (TR);
}
</script>
</body>