开发者

How can I add styles to dynamically added table cells?

In my program I have a table that, when loaded, has jQuery add some styles/classes to the table cells and table headers.

Everything works fine until rows are added via functionality on the rest of the page. Instead of adding the classes to the table cell during addition, is it possible to "listen" or fire some event that checks to see if child elements were added to the table.

Essentially, I want something functionally equivalent to this:

$(开发者_如何学运维"#table td").live("ready", function(){
 // do something
}); 

but the live/ready won't work on a table cell... Any ideas?


You can use a setInterval and then check for the dynamic addition of table cells, if you don't have access to other parts in the page.

setInterval(function(){
    CheckStyles();
}, 1000);

function CheckStyles()
{
    // your code goes here
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜