var str = ""; var arr = document.getElementsByTagName("a"); for (var i = 0; i < arr.length; i++) { if (arr[i].innerText == "VIP") { // 这里的关键字就是你想要的连接名称 // element.td.tr.tbody.table.div.div.span.span var currTd = arr[i].parentNode; var currTr = arr[i].parentNode.parentNode; var currSpan = arr[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; var pLinks = currSpan.getElementsByTagName("a"); var pName = pLinks[pLinks.length - 1].innerText; var index; for (var j = 0; j < currTr.childNodes.length; j++) { if (currTr.childNodes[j].innerHTML == currTd.innerHTML) { index = j; break; } } var cName = currTr.childNodes[index - 3].innerText; str += pName + "-" + cName + "\t" + arr[i] + "<br />"; } } document.writeln(str);