I have a list where SPANs contains a number. I want to "copy" this number in STYLE (set the width as a percentage number) on the SPAN next to it.
HTML
<span class="celebName">Per</span>
<span class="celebPct">32</span>
<span class="celebBar"></span>
JQuery
$('.celebPct').each(function(index) {
var celebPct = $(this).val();
$(this).next(".celebBar").css({"width": + $(celebPct)+"%";});
});
I want the result to be like this:
<span class="celebName">Per</span>
<span class="celebPct">32</span>
<span class="celebBar" style="width:32%;"></span>
Why is this not working?
source
share