老师,把你代码默写下来,一直运行不起来,找bug很不容易。为什么不能回车
RJ
RJ 2017-02-25 15:21:27
0
2
1207
	<body>
		<div id="div1">
			<img /><!--为了书写规范,我回车这行代码,最后运行不了,如果不回车直接跟<div id="div1">就可以正常运行-->
		</div>
	</body>
RJ
RJ

reply all(2)
数据分析师

Teacher, if you write down your code silently, it won’t run all the time. It’s not easy to find bugs. Why can't I press Enter - PHP Chinese website Q&A - Teacher, if you write down your code silently, it won't run all the time. It's not easy to find bugs. Why can't I press Enter - PHP Chinese website Q&A

Take a look around and learn.

阿神

是代码里面node_body.firstChild影响的

1.png

用了回车的话,获取的是div元素下的第一个子节点,这时候这个子节点是一个文本节点,可以看下这篇文章javascript中的firstchild,调试的话,可以尝试像截图12行那样,输出查看下两次获取的imgObj对象有什么区别就能稍微看清楚点了

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template