【发布时间】:2014-03-31 11:03:17
【问题描述】:
我的代码中有一个表格:
<table class="mainTable">
</table>
我想在它前面加上一行。
var filter_all_head_row="
<tr>\
<th>smth</th>\
...
<th>smth</th>\
</tr>
";
我正在尝试使用以下代码在我的页面上加载:
$("table.mainTable").prepend(filter_all_head_row);
通过控制台说:
Uncaught SyntaxError: Unexpected token ILLEGAL
解决方案?
【问题讨论】:
-
我认为更好的方法是用+(加号)来排列html,比如
'<tr>'+ '<th>smth</th>'+等!! -
我认为
/更好,因为这个原因davidwalsh.name/multiline-javascript-strings
标签: javascript jquery html-table prepend