I fixed the issue!
My loop is loading from ajax so:
wrapping
$(document).ajaxComplete(function() {}
on jQuery( “.wpcr_averageStars” ).each(function() {…}
new js code into my theme:
$(document).ajaxComplete(function() {
$( ".wpcr_averageStars" ).each(function() {
//Get the value
var val1 = $(".wpcr_averageStars").attr("id");
//alert(val1);
// Make sure that the value is in 0 - 5 range, multiply to get width
var size1 = Math.max(0, (Math.min(5, val1))) * 16;
// Create stars holder
var $span1 = jQuery('<span />').width(size1);
// Replace the numerical value with stars
$(".wpcr_averageStars").html($span1);
});
});
-
This reply was modified 5 years, 4 months ago by
celik75.