My code is as follows:
<script>
var i = 2;
$("document").ready(function(){
$("#newrow").click(function(){
$("#maintable").append('<tr>
<td><input type="text" name="dept_" + i size="5" maxlength="5" /></td>
<td><input type="text" name="hours_" + i size="5" maxlength="1" /></td>
</tr>');
});
i = i + 1;
});
</script>
Whenever I run it, JavaScript gives me "Uncaught SyntaxError: Unexpected Token ILLEGAL" in the line $ ("# maintable"). append.
In my life I cannot understand what a syntax error is.
This is not a problem with adding the actual item, because I just tried '<td></td>'and got the same error.
source
share