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

160
Vistas
How can I manipulate HTML DOM with data from Database and Node (Mongoose)

Following the tutorial https://www.youtube.com/watch?v=u3rylF3y3og&ab_channel=TraversyMedia

I'm coding something that has a Star review feature. I want to change the width (through document.querySelector('').style.width = starPercentage) of elements to determine how many stars a review gave:

function getRatings() {
      for (let rating in ratings) {
        // Get percentage
        const starPercentage = (ratings[rating] / starsTotal) * 100;

        // Round to nearest 10
        const starPercentageRounded = `${Math.round(starPercentage / 10) * 10}%`;

        // Set width of stars-inner to percentage
        document.querySelector(`.${rating} .stars-inner`).style.width = starPercentageRounded;

        // Add number rating
        document.querySelector(`.${rating} .number-rating`).innerHTML = ratings[rating];
     }
}

But instead of the hard-coded values I'm getting the data from mongoose and express. What's the best way to manipulate the stars of each review?

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

0

The following article contains simple technique for filling star ratings in Javascript. https://webdesign.tutsplus.com/tutorials/a-simple-javascript-technique-for-filling-star-ratings--cms-29450

about 4 years ago · Juan Pablo Isaza Denunciar

0

CSS

and add the correct css to the html class tag for example ( , ....)

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