If/else If/else错误-意外标识符

If/else if/else error - unexpected identifier

本文关键字:If else 标识符 意外 错误      更新时间:2023-09-26

我试图执行一个if/elseif/else语句,但我在第二个else if上得到一个意外的标识符错误。语句的其余部分运行良好。我是一个非常新的编码,所以我道歉,如果这是一个简单的错误。

if (jQuery("#question").val() === "" && (rowCount == 1)) {
    analysis_empty=1;
} else if (rowCount > 1) {
    jQuery('.analysis_empty_title').css({"line-height":"normal"});
    jQuery('.analysis_empty_title').text("Results Displayed by Date Groups");
    jQuery('#here').html(jQuery('#dategrouptable').clone().attr('id', 'tableb_copy'));
    jQuery('#tableb_copy').css({"font-style":"italic"});
    var ptr = jQuery("#tableb_copy").find("tr");    
    ptr.find("td:last").remove();
} else if ((rowCount > 1) and (jQuery("#question").val() != "" )){
    jQuery('#analquestion_empty').css({"display":"none"});//ERROR HERE
} else {
    analysis_empty=0;
    jQuery('#analquestion_empty').css({"display":"none"});
}

任何想法吗?

问题是你使用的and关键字,因为它在Javascript中不存在。

应替换为&&,例如:

else if ((rowCount > 1) && (jQuery("#question").val() != "" )){
with (typeof __commandLineAPI !== 'undefined' ? __commandLineAPI : { __proto__: null }) {
if (jQuery("#question").val() === "" && (rowCount == 1)) {
    analysis_empty=1;
} else if (rowCount > 1) {
    jQuery('.analysis_empty_title').css({"line-height":"normal"});
    jQuery('.analysis_empty_title').text("Results Displayed by Date Groups");
    jQuery('#here').html(jQuery('#dategrouptable').clone().attr('id', 'tableb_copy'));
    jQuery('#tableb_copy').css({"font-style":"italic"});
    var ptr = jQuery("#tableb_copy").find("tr");    
    ptr.find("td:last").remove();
} else if ((rowCount > 1) && (jQuery("#question").val() != "" )){
    jQuery('#analquestion_empty').css({"display":"none"});//ERROR HERE
} else {
    analysis_empty=0;
    jQuery('#analquestion_empty').css({"display":"none"});
}
}