anjia / blog

博客,积累与沉淀
106 stars 4 forks source link

无题.取数据 #66

Open anjia opened 4 years ago

anjia commented 4 years ago

直接在 console 里取数据 :)

1. 表格的第9列

<style>
#tableID td:nth-child(9) {
    background-color: pink;
}
</style>

<script>
var trList = document.querySelectorAll('#tableID tbody tr')

var resList = []
trList.forEach(tr => { resList.push(tr.children[8].innerText) })

console.log(trList.length, resList.length, trList.length===resList.length)
console.log(resList)
</script>