concatenation error in jquery

Posted by Klbaiju under jQuery on 6/15/2015 | Points: 10 | Views : 617 | Status : [Member] | Replies : 1
Hi following is a working code

var j=1;
$('.btn').click(function (e) {
e.preventDefault();
dyntable = "";
j += 1;
count += 8;
dyntable += '<tr id=' + j + '>';

for (i = i; i <= count; i++) {

dyntable += '<td><input width="70px;" class="cp" type="text" id="textbox' + i + '" /></td>';


}

dyntable += '<td><input type="button" value="Add" class="btn"/></td>';
dyntable += '</tr>';
$(dyntable).insertAfter('#1');
$('.cp').width(70);

});


My requirement is to concatenate following statement with j

$(dyntable).insertAfter('#1');

like $(dyntable).insertAfter('#'+j);


i have tried several times like
$(dyntable).insertAfter("#'+j+'");


but not working

how to solve this

Regards

Baiju




Responses

Posted by: Allemahesh on: 3/29/2016 [Member] [MVP] Silver | Points: 25

Up
0
Down
I thing JQuery is not able to find the
$('#1')
control in your code. Please check if you are getting the
$('#1')
undefined or not. If
alert($('#1'))
is undefined then it will not work. Please check it.

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response