代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<body>
<table border="0" cellspacing="0" cellpadding="0" id="myTable">
<tr id="row1">
<td>书名</td>
<td>价格</td>
</tr>
<tr id="row2">
<td>看得见风景的房间</td>
<td class="center">¥30.00</td>
</tr>
<tr id="row3">
<td>60个瞬间</td>
<td class="center">¥32.00</td>
</tr>
</table>
<input name="b1" type="button" value="增加一行" onclick="addRow()" />
<input name="b2" type="button" value="删除第2行" onclick="delRow()" />
<input name="b3" type="button" value="修改标题样式" onclick="updateRow()" />
<input name="b4" type="button" value="复制最后一行" onclick="copyRow()" />
</body>
<script>
function addRow() {
var table = document.getElementById("myTable");
var newRow = table.insertRow(table.rows.length);
var cell1 = newRow.insertCell(0);
var cell2 = newRow.insertCell(1);
cell1.innerHTML = "三国";
cell2.innerHTML = "¥197.00";
}
function delRow() {
var table = document.getElementById("myTable");
table.deleteRow(2);
}
function updateRow() {
var row1 = document.getElementById("row1");
row1.style.backgroundColor = "lightblue";
row1.style.color = "white";
}
function copyRow() {
var table = document.getElementById("myTable");
var lastRow = table.rows[table.rows.length-1];
var newRow = lastRow.cloneNode(true);
table.appendChild(newRow);
}
</script>
</head>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。