为什么会报错?是这样获取的啊
Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
at window.onload (11.html:33)
<script>
window.onload = function(){
var box = document.getElementById('content');
var imgs = box.getElementsByTagName('img');
var imgWidth = imgs[0].offsetWidth;
var exp = 180;
var boxWidth = imgWidth + (imgs.length - 1)*exp;
box.style.width = boxWidth + 'px';
for(var i=1,len=imgs.length;i<len;i++){
imgs[i].style.left=imgWidth+exp*(i-1)+'px';
}
};
</script>