<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
.tbale{
border:1px solid red;
}
</style>
</head>
<body>
<table class="table">
<tr>
<td>111111</td>
<td>222222</td>
</tr>
<tr>
<td>3333333</td>
<td>4444444</td>
</tr>
<tr>
<td>5555</td>
<td>6666</td>
</tr>
</table>
</body>
<script type="text/javascript">
var tags = document.getElementsByTagName('*'); //获取所有标签节点
var j=tags.length; //统计全部节点个数
console.log(j);
var tagsArr = []; //创建空数组缓冲区
function countTag(){
for (var i = 0; i < tags.length; i++) {
var res=(tags[i].tagName).toUpperCase();
if(tagsArr.indexOf(res)<0){ //判断数组是否已经存在该标签
tagsArr.push(res); //对标签节点做格式调整,全部转化为小写字母
}
}
console.log(tagsArr);
</script>
</html>
结果: