Javascript .append动态表的Js未终止字符串常量
我正在使用数组中的数据动态创建表:Javascript .append动态表的Js未终止字符串常量,javascript,Javascript,我正在使用数组中的数据动态创建表: var toAppend = $("#tablediv"); toAppend.append("<table id=\"grid\"><tr><th>(labels)</th>"); for (var f = 0; f < seriescount; f++) { toAppend.append("<th>" + series[f] + "</th>"); } toAppend
var toAppend = $("#tablediv");
toAppend.append("<table id=\"grid\"><tr><th>(labels)</th>");
for (var f = 0; f < seriescount; f++)
{
toAppend.append("<th>" + series[f] + "</th>");
}
toAppend.append("</tr></table>");
var toAppend=$(“#tablediv”);
附加(“(标签)”);
对于(var f=0;f
最后一行返回“unterminated string constant”错误。这可以通过删除行或更改其内容来消除-这与它作为结束标记有关
此代码位于C#Razor中的标记中。文档片段始终处于关闭状态。不能附加半个元素 所以当你这么做的时候
toAppend.append("<table id=\"grid\"><tr><th>(labels)</th>");
toAppend.append("<table id=\"grid\"><tr><th>(labels)</th></tr></table>");
var h = "<table id=grid><tr><th>(labels)</th>";
for (var f = 0; f < seriescount; f++) {
h += "<th>" + series[f] + "</th>";
}
h += "</tr></table>";
$("#tablediv").append(h);