Documentation:
http://docs.jquery.com/CSS

$("#myElem").css('color', '#ff0000');

It would probably be better if 'cat_[id]' is the element's ID rather
than a CLASS, provided that it's unique in the whole document:
<div id="cat_12">...</div>

Using that, you can easily update a whole set of 'cat_[id]' in one
call (if that's what you want to do):
$("[id^=cat_]").css('color', '#ff0000');
This will update every element with IDs that begin with 'cat_'.

Theoretically you can do that with CLASS also, but when the CLASS
attribute also allows definition of multiple classes, such as:
class="header cat_45"
in which case would require a bit more work to locate because it would
not fall in the criteria of "begins with cat_" anymore.

On Mar 29, 4:23 am, Lars Schöning <tahp...@gmail.com> wrote:
> Hello,
>
> Apologies if this turns out to be a trivial question. I currently am
> working with jQuery on a set of elements assigned to colored
> categories via a 'cat_[id]' class. Categories can change colors and if
> they do I want to update the color of every elements belonging to it.
> I want the same to be true in all new events added.
>
> I would believe that the easiest solution to this problem would be
> changing the 'color' attribute directly in the CSS class 'cat_[id]',
> but have found no way to do so. As I am fairly new to jQuery I might
> also be overseeing a much more elegant solution. Can anyone clarify?
>
> Thanks in advance,
> Lars

Reply via email to