Reputation: 2245
I have a table in my code:
<table class="mainTable">
</table>
I want to prepend a head row to it.
var filter_all_head_row="
<tr>\
<th>smth</th>\
...
<th>smth</th>\
</tr>
";
I'm trying to do it in onload of my page with this code:
$("table.mainTable").prepend(filter_all_head_row);
By the console says:
Uncaught SyntaxError: Unexpected token ILLEGAL
Solutions?
Upvotes: 0
Views: 236
Reputation: 4056
Try this solution
var filter_all_head_row = '<tr>\
<th>smth</th>\
<th>smth</th>\
</tr>';
you wrote like this
var filter_all_head_row = '
......
It should be like this
var filter_all_head_row = '\
......
Because every time you want to go next line you have to put this \
.
Also recommended that use some tool
like Adobe Dreamviewer
etc they will show this type of errors
during writing of you code
Upvotes: 2
Reputation: 272106
You are missing at least two \
in your string literal:
var filter_all_head_row="
<tr>\
<th>smth</th>\
<th>smth</th>\
</tr>
";
Should be:
var filter_all_head_row = "\
<tr>\
<th>smth</th>\
<th>smth</th>\
</tr>\
";
Upvotes: 1