What I have is a number of divs, belonging to several categories.
These divs come and go. The color of a div should be determined by the
color defined for the category they belong to; category colors change
as well.
Say we're dealing with just a single category, colored red. One div
might be
Since you want the style to update when the color changes and when you
add or modify elements, why not dynamically create style tags in the
document head and let the browser do the work?
$('head').append('style type=text/css.cat_1 {color: #ff}/
style')
You could leave it at that and keep
You can modify the CSS rules directly, see this plugin:
http://flesler.blogspot.com/2007/11/jqueryrule.html
I wrote this a while back, not thorougly tested. I guess adding a new
class rule to the end of the stylesheet will override previous rules
(this only adds to the first stylesheet in the
Documentation:
http://docs.jquery.com/CSS
$(#myElem).css('color', '#ff');
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
4 matches
Mail list logo