<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title></title> <script> window.onload = function(){ var mybox = document.getElementsByTagName("li"); document.write('<xmp>'+mybox[0].innerHTML+'</xmp>'); alert(mybox[0].innerHTML); console.log(mybox[0].innerHTML); } </script></head><body> <ul id="box"> <li><img src="image/i1.png" alt=""></li> <li><img src="image/i2.png" alt=""></li> <li><img src="image/i3.png" alt=""></li> </ul> </body></html>我发现 window.onload = function(){ var mybox = document.getElementsByTagName("li"); document.write('<xmp>'+mybox[0].innerHTML+'</xmp>'); alert(mybox[0].innerHTML); console.log(mybox[0].innerHTML); } 里面的三句话: document.write('<xmp>'+mybox[0].innerHTML+'</xmp>'); alert(mybox[0].innerHTML); console.log(mybox[0].innerHTML); 只有一句可以执行document.write('<xmp>'+mybox[0].innerHTML+'</xmp>');为何执行完 document.write('<xmp>'+mybox[0].innerHTML+'</xmp>'); 后面的两句不执行了? alert(mybox[0].innerHTML); console.log(mybox[0].innerHTML);
4 回答
守候你守候我
TA贡献1802条经验 获得超10个赞
MYYA
TA贡献1868条经验 获得超4个赞
window.onload = function(){
var mybox = document.getElementsByTagName("li");
document.write('<xmp>'+mybox[0].innerHTML+'</xmp>');
alert(mybox[0].innerHTML);
console.log(mybox[0].innerHTML);
}
改写成
window.onload = function(){
var mybox = document.getElementsByTagName("li");
alert(mybox[0].innerHTML);
console.log(mybox[0].innerHTML);
document.write('<xmp>'+mybox[0].innerHTML+'</xmp>');
}
添加回答
举报
0/150
提交
取消