Can I add a unique id attribute to a td from jquery?
I have a table being populated and I would like the td id to be the id number for the data that开发者_开发问答 was returned. How do I assign an id to a td from jquery?
var $tr = $('<tr><td class="name"></td></tr>').insertAfter('#newTable tr:last');
$tr.find('.name').html(data.Name);
//How do I assign data.id to <td class="name"> ?
This should work:
$tr.find('.name').attr('id', data.id).html(data.Name);
$('.name').attr('id', data.id)
精彩评论