为了账号安全,请及时绑定邮箱和手机立即绑定

为什么输出结果是:c.firstchild is undefined ,不是已经var C=document.getElementsByTagName("p");了么

为什么输出结果是:c.firstchild is undefined ,不是已经var C=document.getElementsByTagName("p");了么

慕粉3541299 2016-10-10 16:55:17
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title></head><body><ul><li id="bj" value="beijing">北京<p>海淀</p>  奥运</li><li id="sh" value="shanghai" >上海</li></ul><script>var A=document.getElementById("bj");var C=document.getElementsByTagName("p");alert(A.firstChild.nodeValue+C.firstChild.nodeValue+A.lastChild.nodeValue);</script></body></html>
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1328 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信