簡體   English   中英

$ .each()里面的“意外的令牌”

[英]“Unexpected token else” inside $.each()

出於某種原因,我為此腳本收到了一個Unexpected token else錯誤:

.each(rowValue.columns, function(columnKey, columnValue){
    if(typeof rowValue.type !== 'undefined' && rowValue.type == 'header'){
        $(this).append(
            $('<div></div>').prop('name', columnValue.name).text(columnValue.text).addClass('orangeStatusTwoThirdsCell blueCellOverride').applyHTMLclasses(columnValue.classes);
        );
    }
    else if(columnValue.inputType == 'textarea'){
        $(this).append(
            $('<textarea></textarea>').prop('rows', columnValue.textareaRows).prop('id', columnValue.id).addClass('fillContainer inputAsCell hideScrollbar').applyHTMLclasses(columnValue.classes);
        );
    }
    else if(columnValue.inputType == 'select'){
        $(this).append(
            $('<select></select>').prop('id', columnValue.id).addClass('fillContainer inputAsCell').applyHTMLclasses(columnValue.classes).append(function(){
                if(typeof columnValue.valuelessSelectOption !== 'undefined'){$(this).append($('<option/>').text(columnValue.valuelessSelectOption));}
            });
        );
    }
});

我將$.append()用於動態構造的元素。

去除 ; 在這條中間線的末尾:

if(typeof rowValue.type !== 'undefined' && rowValue.type == 'header'){
    $(this).append(
        $('<div></div>').prop('name', columnValue.name).text(columnValue.text).addClass('orangeStatusTwoThirdsCell blueCellOverride').applyHTMLclasses(columnValue.classes);
    );
}

之后幾行有同樣的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM