On Tue, Dec 1, 2009 at 9:53 PM, led <l.r....@sapo.pt> wrote:

> I'm try to use star rating plugin frm
> http://fyneworks.com/jquery/star-rating/.
>
> I need to add class 'star-rating-on' on the divs  with class 'star-
> rating rater-0 auto-submit-star star-rating-applied star-rating-
> live' .
>

That's not a class, it's five classes. Spaces in a class attribute value
separate multiple class names.


>
> I can use:
>
> $("div.star-rating rater-0 auto-submit-star star-rating-applied star-
> rating-live")


that selector is looking for all elements of type star-rating-live within an
element of type star-rating-applied within an element of type
auto-submit-star within an element of type rater-0 within an element of type
div with a class of star-rating. In this case the space acts as a descendant
selector. That would only do if your markup looked something like this

<div class="star-rating">
  <rater-0>
    <auto-submit-star>
      <star-rating-applied>
        <star-rating-live>
        </star-rating-live>
      </star-rating-applied>
    </auto-submit-star>
  </rater-0>
</div>

and it would match the star-rating-live element, not the div.


> .each(function(){
>                                        $(this).addClass('star-rating-
> on')
>                                });
> but it isn't working.
>

If you really only want the divs with all those classes:

$('div.star-rating').filter('.rater-0').filter('.auto-submit-star').filter('.star-rating-applied').filter('.star-rating-live').addClass('star-rating-on');

or more succinctly:

$('div.star-rating.rater-0.auto-submit-star.star-rating-applied.star-rating-live').addClass('star-rating-on');

- Richard

Reply via email to