开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜