Reputation: 51
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 every time I bind data to a table.
$("table tr:odd td").addClass("rowalt");
Upvotes: 0
Views: 1146
Reputation: 30520
Can you not just specify this in CSS?
table tr:odd td
{
//my CSS Styles
}
Upvotes: 1
Reputation: 339927
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.
Upvotes: 0