js中关于getElementsByTagName的问题
<p>HelloWorld!</p><p>TheDOMisveryuseful!</p><p>Thisexampledemonstratesthe<b>getElemen...
<p>Hello World!</p>
<p>The DOM is very useful!</p>
<p>This example demonstrates the <b>getElementsByTagName</b> method.</p>
<script>
x=document.getElementsByTagName("p");
document.write("Text of first paragraph: " + x[5].innerHTML);
</script>
问题:
x[5]的值不存在,为什么这一句就不执行了document.write?为什么不直接输出Text of first paragraph: 展开
<p>The DOM is very useful!</p>
<p>This example demonstrates the <b>getElementsByTagName</b> method.</p>
<script>
x=document.getElementsByTagName("p");
document.write("Text of first paragraph: " + x[5].innerHTML);
</script>
问题:
x[5]的值不存在,为什么这一句就不执行了document.write?为什么不直接输出Text of first paragraph: 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询