<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
i=0;
function huo(){
//var y =document.getElementById("huoqu");
var y =document.getElementsByTagName("div");
for(var i=0;i<y.length;i++){
var h=y[i].childNodes;
document.write(h[1].title+"<br>");
}
}
</script>
</head>
<body>
<input type="button" value="获取" onclick="huo()">
<li>
<div class="pic170" id="huoqu" >
<a href="//my.tv.sohu.com/us/201854050/71958.shtml" title="影视剧26" target="_blank" pb-url="meta$$mts$$mtsNew$$mtsModule" _s_c="100" _s_pos="video" _s_pos_new="videoNew" _s_type="img" _s_d="sohu" _s_a="0" _s_v="71691958" _s_n="0" _s_ep _s_loc="1" _s_b="0" _s_algid="100000">
</a>
</div>
</li>
<li>
<div class="pic170" >
<a href="//my.tv.sohu.com/us/200648894/634636.shtml" title="影视剧225" target="_blank" pb-url="meta$$mts$$mtsNew$$mtsModule" _s_c="120" _s_pos="video" _s_pos_new="videoNew" _s_type="img" _s_d="sohu" _s_a="0" _s_v="63461336" _s_n="0" _s_ep _s_loc="2" _s_b="0" _s_algid="100000">
</a>
</div>
</li>
<li>
<div class="pic170" >
<a href="//my.tv.sohu.com/us/200648894/634636.shtml" title="影视剧7s" target="_blank" pb-url="meta$$mts$$mtsNew$$mtsModule" _s_c="120" _s_pos="video" _s_pos_new="videoNew" _s_type="img" _s_d="sohu" _s_a="0" _s_v="63461336" _s_n="0" _s_ep _s_loc="2" _s_b="0" _s_algid="100000">
</a>
</div>
</li>
document.write(h[1].title+"<br>")这里的输出写的h[1],所以只显示第二个div的title,想要循环写成h[i]
用alert()弹出或者console.log()在浏览器控制台输出
函数里第一次调用document.write()把其它内容覆盖了