Using the code below I can insert a new row to my table (#courseelements).
$("#addbutton").click(function() {
$('#courseelements > tbody:last').append('<tr><td>Helloworld</td></tr>');
});
However, I’d like to replace the Helloworld with a <select> element. So something like this:
$("#addbutton").click(function() {
$('#courseelements > tbody:last').append('<tr><td>
<select class='plan_id'>
<option value='1'>Description</option>
<option value='2'>Description</option>
<option value='3'>Description</option>
</select>
</td></tr>');
});
But this gives me “missing ) after argument list” on the first apostrophe ‘ <select class='
Any ideas why?
You forgot to escape quotes:
As alternative you can wrap whole appended string in double quotes insetead of single quotes: