how to change a div class based off a variable.
Hi
I have this static div on a page:
<div class="stars stars-40"></div>
I have a variable called {rating} in my template. The variable is always in .5 increments, .5 to 5.0 and I have the appropriate classes in my style sheet.
If the rating is 3.5, I want to change the class in the div to:
<div class="stars stars-35"></div>
What is a good way to do this?
I was thinking in jQuery I could do this:
var
s
=
'{rating}'
.
replace
(
/\./
g
,
''
);
to strip out the decimal. But I'm not sure on how to make the div update with the "35" value? I'm not sure on the jQuery selector I should use either.
Thanks.
-JBD