首页 > window.onload不执行?

window.onload不执行?

js dom编程艺术这本书第四章4.4.1
代码:


    function showPic (whichPic) {
        var source = whichPic.getAttribute('href');
        var placeholder = document.getElementById('placeholder');
        placeholder.setAttribute('src',source);
    
    }
    function countBodyChildren(){
        var body_element = document.getElementByTagName("body")[0];
        alert(body_element.childNodes.length);
    
    }    
    window.onload = countBodyChildren;

`请输入代码`

应该有报错啊,拼错啦


是getElementsByTagName,少了个s

【热门文章】
【热门文章】