Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
I want to convert radio buttons into star for star rating . i followed various tutorials but none works for me

$(".rating input:radio").attr("checked", false);

$('.rating input').click(function() {
  $(".rating span").removeClass('checked');
  $(this).parent().addClass('checked');
});

$('input:radio').change(function() {
  var userRating = this.value;
  alert(userRating);
});
.rating {
  float: left;
  width: 300px;
}

.rating span {
  float: right;
  position: relative;
}

.rating span input {
  position: absolute;
  top: 0px;
  left: 0px;
  opacity: 0;
}

.rating span label {
  display: inline-block;
  width: 30px;
  height: 30px;
  text-align: center;
  color: #FFF;
  background: #ccc;
  font-size: 30px;
  margin-right: 2px;
  line-height: 30px;
  border-radius: 50%;
  -webkit-border-radius: 50%;
}

.rating span:hover~span label,
.rating span:hover label,
.rating span.checked label,
.rating span.checked~span label {
  background: #F90;
  color: #FFF;
}
<html>

<head>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script>
</head>

<body>
  <form method="post" action="star.php">
    <div class="rating">
      <span><input type="radio" name="ratingg" id="str5" value="5"><label for="str5"></label></span>
      <span><input type="radio" name="ratingg" id="str4" value="4"><label for="str4"></label></span>
      <span><input type="radio" name="ratingg" id="str3" value="3"><label for="str3"></label></span>
      <span><input type="radio" name="ratingg" id="str2" value="2"><label for="str2"></label></span>
      <span><input type="radio" name="ratingg" id="str1" value="1"><label for="str1"></label></span>
    </div>
    <label for="review">Your review about the place.</label>
    <textarea name="review" id="review" col="5" row="30"></textarea>
    <input type="hidden" name="product_id" id="product_id" value="<?=$row['id']?>">
    <input type="submit" name="submit">
  </form>
</body>

</html>

everything is working fine.i Just need these radio buttons to be displayed as star .help me with css Please.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

please use font awesome icon here is the link

https://fontawesome.com/icons

search for the star icon you get the suitable icon as you want and put it into the label tag you have put in your code.

<label><i class="fa-solid fa-star"></i></label>

this is the JS file link please download the file from here which is used to show the icons.

https://drive.google.com/file/d/1eLhUjVd4ldCFmIgJLkUtFVfLUjEYZdW5/view?usp=sharing

and then make replace the following css code which you have done.

.rating span label {
  display: inline-block;
  width: 30px;
  height: 30px;
  text-align: center;
  color: #ccc;
  font-size: 30px;
  margin-right: 2px;
  line-height: 30px;
  border-radius: 50%;
  -webkit-border-radius: 50%;
}

.rating span:hover~span label,
.rating span:hover label,
.rating span.checked label,
.rating span.checked~span label {
  color: #F90;
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda