Reputation: 236
I'm trying to implement a dynamic input field on jQuery. But nothing is happening in this code. Somehow i believe the error is syntax related, or at least related to jquery fundamentals so i apologize in advance.
var add = function(){
var intID = $('#target').length+1;
var row = $('<tr id=\"row'+intID+'\">row</tr>');
var data_1 = $('<td><input type=\"text\" name=\"part'.intID.'\"/></td>');
var data_2 = $('<td><input type=\"text\" name=\"pos'.intID.'\"/></td>');
var remove_button = $('<td><input type=\"button\" onclick=\"$(this).parent().parent().remove()\"/></td>');
$(row).append(data_1);
$(row).append(data_2);
$(row).append(remove_button);
$('#target').append(row);
}
The target is an empty table and im trying to add and remove the appropriate rows.
Upvotes: 0
Views: 80
Reputation: 10617
Your are concatenating incorrectly. .intID.
should be +intID+
.
Upvotes: 2