WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im looking a way to change the following HTML:

<div class="votes">Rating: <strong>+5</strong> (from 5 votes)</div>

and produce:

<div class="votes"><div class="calculated-rating">+5</div></div>

Thanks in advance.

share|improve this question
up vote 4 down vote accepted
<script type="text/javascript">
        votes = jQuery('strong',this).html();
        jQuery(this).html('<div class="calculated-rating">'+votes+'</div>');
share|improve this answer
jsfiddle.net/68CjG – Geert May 8 '11 at 7:19
Nice. It owrks like a charm. Thanks. – José Pablo Orozco Marín May 17 '11 at 8:59

Its little short.

<script type="text/javascript">
var tmp = jQuery(".votes strong").html();
jQuery(".votes").html('<div class="calculated-rating">'+tmp+'</div>')
share|improve this answer
this will only work if there is one instance of .votes, otherwise every .votes div will show the value of the first instance. – Milo May 21 '11 at 17:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.