innerHtml表单数组

时间:2014-09-24 08:21:09

标签: javascript innerhtml

我已阅读这篇文章Need helping with innerHTML and array input variables。但是当我这样做时:

 if (errors.length > 0) {
    var htmlErrors ='';
    for (var i = 0; i < errors.length; i++) {    
        htmlErrors += errors[i];
    }
    document.getElementById("registration_errors").innerHtml = htmlErrors;

我得到白屏。我的错误在哪里?

2 个答案:

答案 0 :(得分:3)

尝试:innerHTML Link

document.getElementById("registration_errors").innerHTML = htmlErrors;

答案 1 :(得分:1)

if未关闭,而innerHTML代替innerHtml

if (errors.length > 0) {
    var htmlErrors ='';
    for (var i = 0; i < errors.length; i++) {    
        htmlErrors += errors[i];
    }
    document.getElementById("registration_errors").innerHTML = htmlErrors;
}