1、访问一个页面,如:
2、打开console,输入:
//获取节点,根据类名 var x=document.getElementsByClassName("toplist1-td opr-toplist1-link"); var sum=""; for(var i=0;i<x.length;i++){ //console.log(i); //console.log(x[i]); var a=x[i].getElementsByTagName("a"); for(var j=0;j<a.length;j++){ console.log(i+1); var tmp=a[j].getAttribute("title"); console.log(tmp); sum = sum + "【"+ tmp +"】" + " & "; //console.log(sum); } } console.log(sum);