How do I set an ID or class on the TH of a column in javascript?
How do I set an ID or class on the TH of a column in javascript?

I'd like to set an id or class on JUST a column header. I know I can set className on a column definition, but that's set the class on all the cells, and I just want it set on the header.
I'm trying to access the column header to dynamically change it, but having a hard time figuring out how. I can add a className, then just get it by "th .<className>", but that's awkward. I want to avoid using numeric indexes altogether.
Are there any column options that are specific to the header, besides title? There's a name, which I've set, but that doesn't render anything. So maybe there's some way to search for a column by name, get the header, and then set the contents?
Thanks.
Answers
I think that
columns().header()
should help. The first example shows removing a class but you you should be able toaddClass()
instead and just have it apply to the header. Note the use ofto$()
to get a jQuery object for this to work.Kevin