开发者

jQuery - Automatically apply style after dynamic table creation

Is there a way to automatically apply a style to every table that is created, including dynamically created tables? I'm imagining it will be possible using .live() or .delegate() but not sure which event type to attach to.

The code below works but has to be called ever开发者_开发技巧y time I bind data to a table.

$("table tr:odd td").addClass("rowalt");


Can you not just specify this in CSS?

table tr:odd td
{
    //my CSS Styles
}


You can catch DOM Change Events when the tree changes, but I don't believe that's widely supported.

If you can't just fix the style in your CSS file, then just adding the class as you are seems fine to me.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜