I haven’t seen any docs saying jQuery can change any CSS definition such as changing
td { padding: 0.2em 1.2em }
to
td { padding: 0.32em 2em }
but either have to change a whole style sheet, or change class of each element, or change css of each element.
Is changing the style definition possible?
There is DOM access to stylesheets, but it’s one of those things we tend to avoid because IE needs a load of compatibility cruft.
A better way would be typically be to trigger the change indirectly, using a simple class change on an ancestor:
Now just
$('body').addClass('changed')and all thetds update.If you really must frob the stylesheets:
This assumes that the
tdrule in question is the first rule in the first stylesheet. If not, you might have to go searching for it by iterating the rules looking for the right selectorText. Or just add a new rule to the end, overriding the old one:jQuery itself doesn’t give you any special tools to access stylesheets, but it’s possible there are plugins that might.