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

240
Views
Necesito cambiar el color de la fuente. Si pasó = verde y Falló = rojo pero está en la tabla (Declaración de bucle), así que no lo sé
var x = 65; do { if (x >= 75) { // The line while be printer even // if the condition is false document.write("<tr><td>"); document.write(x); document.write("</td>"); document.write("<td>"); document.write("FAILED"); document.write("</td>"); } else { document.write("<tr><td>"); document.write(x); document.write("</td>"); document.write("<td>"); document.write("PASSED"); document.write("</td>"); }

Así que aquí necesito que sea Color rojo cuando falla y verde cuando pasa, pero sé cómo cambiar el color de la fuente, pero no lo sé cuando está en la tabla y necesito ser una declaración if-else. ¡Por favor ayuda!

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Establezca el color a través de un atributo de estilo: style="color:red" o style="color:green" en el <tr>

como esto:

 var x = 65; do { if (x >= 75) { // The line while be printer even // if the condition is false document.write("<tr style='color=red'><td>"); document.write(x); document.write("</td>"); document.write("<td>"); document.write("FAILED"); document.write("</td>"); } else { document.write("<tr style='color=green'><td>"); document.write(x); document.write("</td>"); document.write("<td>"); document.write("PASSED"); document.write("</td>"); }

Por supuesto, podría / debería hacer esto no a través de estilos en línea, sino poner las definiciones en clases css y luego poner la clase en las filas.

about 4 years ago · Santiago Trujillo Report

0

#red { color:red; } #green { color:green; } document.write('<p id="red">FAILED</p>') document.write('<p id="green">PASSED</p>')
about 4 years ago · Santiago Trujillo Report
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!