无法解决此错误:未关闭的字符串

我无法解决语法错误。未关闭的字符串是我尝试验证它时的错误。


function addNewCultureRow($row, $case, $specimen) {

    var $uniqueID = "." + $row + $case + "." + $specimen;

    var $tableRows = "<tr><td>" + $row + "<td><input id='localLevel" + $uniqueID + '" type="edit">' +

                        "<td><input id='colony" + $uniqueID + '" type="edit">' +

                        "<td><input id='description" + $uniqueID + '" type="edit">' +

                        "<td><input id='oxidase" + $uniqueID + '" type="edit">' +

                        "<td><input id='isolation1" + $uniqueID + '" type="edit">' +

                        "<td><input id='isolation2" + $uniqueID + '" type="edit">' +

                        "<td><input id='bioChemComments" + $uniqueID + '" type="edit">' +

                        "<td><input id='IDMALDI" + $uniqueID + '" type="edit">' +

                        "<td><input id='sensiID" + $uniqueID + '" type="edit">' +

                        "<td><input id='organism-" + $case + "-" + $specimen + "544' type='select'>" +

                        "<td><input id='localComments" + $uniqueID + '" type="edit">' +

                        "<td><input id='comments-" + $case + "-" + $specimen + "-544-new' type='edit'>" +

                        "<td><input id='result-" + $case + "-" + $specimen + "544-new' type='select'>";

    return ($tableRows);

}


一只甜甜圈
浏览 375回答 3
3回答

MM们

我认为这是来自这一行"<td><input&nbsp;id='colony"您需要关闭内部报价。

茅侃侃

Thakur 在他的回答中是正确的,你有 ' 和 " 混淆了几次。如果你想在未来避免这种问题,你可能需要考虑使用模板字符串,例如:var $tableRows = `<tr><td>${$row}<td><input id='localLevel ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='colony ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='description ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='oxidase ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='isolation1 ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='isolation2 ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='bioChemComments ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='IDMALDI ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='sensiID ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='organism-${$case}-${$specimen}-544' type='select'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='localComments ${$uniqueID}' type="edit">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='comments-${$case}-${$specimen}-544-new' type='edit'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><input id='result-${$case}-${$specimen}-544-n' type='edit'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `;

米脂

将所有 '" 反转为 "' 并且 type="edit" 应该是 type='edit' ,如下所示:function addNewCultureRow($row, $case, $specimen) {&nbsp; &nbsp; var $uniqueID = "." + $row + $case + "." + $specimen;&nbsp; &nbsp; var $tableRows = "<tr><td>" + $row + "<td><input id='localLevel" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='colony" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='description" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='oxidase" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='isolation1" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='isolation2" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='bioChemComments" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='IDMALDI" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='sensiID" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='organism-" + $case + "-" + $specimen + "544' type='select'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='localComments" + $uniqueID + "' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='comments-" + $case + "-" + $specimen + "-544-new' type='edit'>" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "<td><input id='result-" + $case + "-" + $specimen + "544-new' type='select'>";&nbsp; &nbsp; return ($tableRows);}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript