Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
Pintar números con Javascript

No encontré nada relacionado en internet.

Necesito un código javascript que me devuelva el color verde o rojo según el número.

Pero no quiero que sea estático, por ejemplo, cuanto más negativo, más rojo se vuelve. Y cuanto más positivo, más verde se vuelve.

-1 y 1 tendrían colores claros, por ejemplo, 1000 y -1000 serían más fuertes. Similar a lo que se hace en Excel y Google Spreadsheet.

esto es lo que probé con los números negativos:

detalle: no quiero que 255 sea el máximo o el mínimo

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Test</title> </head> <body> <div id="number"> -100 </div> </body> <script> var div = document.querySelector('#number'); var number = Number(document.querySelector('#number').innerText); var redRgb = 255; console.dir(redRgb + number); div.style.color = `rgb(${redRgb + number},0,0)`; </script> </html>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!