Saleem
Saleem

Reputation: 1049

Script is working with jquery 1.3.2 but not with jquery 1.7.2

I am trying to add extra input fields but this code works with jquery 1.3 once i try with jquery 1.7. It doesn't work

var newTr = $(document.createElement('tr'))
         .attr("id", 'line' + counter);

    newTr.after().html('<td><input type="text" name="name' + counter + 
          '" id="name' + counter + '" value="" style="width:100px;"></td><td><input type="text" name="phone' + counter + 
          '" id="phone' + counter + '" value="" style="width:100px;"></td>');

    newTr.appendTo("#dyTable");

I guess there is problem with newTr.after().html() and newTr.appendTo("#dyTable"); Please help me

Upvotes: 0

Views: 140

Answers (1)

Muthu Kumaran
Muthu Kumaran

Reputation: 17910

document.createElement('tr') is not needed and you can simply use $('<tr></tr>') to create new element. This should work,

var newTr = $('<tr></tr>').attr("id", 'line' + counter);

For adding <td> content, change, newTr.after().html('...') to newTr.html('...'). I don't think after is required.

Upvotes: 2

Related Questions