console
window.onload = function ()
{
var oTds = document.getElementsByTagName("td");
for(var i = 0; i < oTds.length; ++i) {
oTds[i].onclick = function () {
var oParent = this.parentNode;
oParent.style.color = "white";
oParent.style.backgroundColor = "lightskyblue";
}
}
var oUl = document.getElementById("list");
var oChildNodes = oUl.childNodes;
var oChildElements = oUl.children;
console.log("There are " + oChildNodes.length + " child nodes in list.");
console.log("There are " + oChildElements.length + " child element nodes in list.");
var oBtn = document.getElementById("btn");
oBtn.onclick = function() {
var preLastNode = oUl.lastElementChild.previousSibling;
oUl.removeChild(preLastNode);
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
</style>
<script>
</script>
</head>
<body>
<table>
<caption>考试成绩表</caption>
<tr>
<td>小明</td>
<td>80</td>
<td>80</td>
<td>80</td>
</tr>
<tr>
<td>小红</td>
<td>90</td>
<td>90</td>
<td>90</td>
</tr>
<tr>
<td>小杰</td>
<td>100</td>
<td>100</td>
<td>100</td>
</tr>
</table>
<ul id="list">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<li>jQuery</li>
<li>Vue.js</li>
</ul>
<button id="btn">删除</button>
</body>
</html>
table{
border-collapse:collapse;
}
table,tr,td{
border:1px solid gray;
}