請問為什么不能循環呢?
<!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 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 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 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>
2017-08-30
document.write(h[1].title+"<br>")這里的輸出寫的h[1],所以只顯示第二個div的title,想要循環寫成h[i]
2017-07-28
用alert()彈出或者console.log()在瀏覽器控制臺輸出
2017-07-28
函數里第一次調用document.write()把其它內容覆蓋了