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

159
Views
¿Cómo dar color de fondo a <td> específico? Para eso, tengo que ingresar el número de posición en el tercer cuadro de texto (usando java script)

Creé tres cuadros de texto.

  • El primer cuadro de texto toma un número como una fila
  • El segundo cuadro de texto toma un número como columna
  • El tercer cuadro de texto toma un número (posición) para resaltar ese número en la tabla
  • cómo hacer el tercer punto en javascript
 <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"> <script src="7.js"></script> <title>Document</title> </head> <body> <input type="text" name="" id="text1"> <input type="text" name="" id="text2"> <label for="color">Which cell to color</label> <input type="text" name="" id="color"> <input type="button" value="Generate" onclick="h()"> <br> <!--javascript code--> <script> function h(){ var a=document.getElementById("text1").value; var b=document.getElementById("text2").value; var col=document.getElementById("color").value; var g=parseInt(col); document.write("<table border='1'>"); var c=1; for(i=0;i<a;i++) { document.write("<tr>"); for(j=0;j<b;j++) { document.write("<td>",c++,"</td>"); } document.write("</tr>"); } document.write("</table>"); } </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

 <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"> <script src="7.js"></script> <title>Document</title> </head> <body> <input type="text" name="" id="text1"> <input type="text" name="" id="text2"> <label for="color">Which cell to color</label> <input type="text" name="" id="color"> <input type="button" value="Generate" onclick="h()"> <br> <!--javascript code--> <script> function h() { var a = document.getElementById("text1").value; var b = document.getElementById("text2").value; var col = document.getElementById("color").value; var g = parseInt(col); document.write("<table border='1'>"); var c = 1; for (i = 0; i < a; i++) { document.write("<tr>"); for (j = 0; j < b; j++) { if (parseInt(col) == c) { console.log(col) document.write("<td style='background-color: yellow;'>", c++, "</td>"); } else { document.write("<td>", c++, "</td>"); } } document.write("</tr>"); } document.write("</table>"); } </script> </body> </html>

about 4 years ago · Juan Pablo Isaza Report

0

establecer el fondo de todas las td n-ésima posición

 <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"> <script src="7.js"></script> <title>Document</title> </head> <body> <input type="text" name="" id="text1"> <input type="text" name="" id="text2"> <label for="color">Which cell to color</label> <input type="text" name="" id="color"> <input type="button" value="Generate" onclick="h()"> <br> <!--javascript code--> <script> function h(){ var a=document.getElementById("text1").value; var b=document.getElementById("text2").value; var col=document.getElementById("color").value; var g=parseInt(col); document.write("<table border='1'>"); var c=1; for(i=0;i<a;i++){ document.write("<tr>"); for(j=0;j<b;j++){ var background = ''; if(g == j){ background = 'style="background-color:red"'; } document.write("<td "+background+">",c++,"</td>"); } document.write("</tr>"); } document.write("</table>"); } </script> </body> </html>

about 4 years ago · Juan Pablo Isaza 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!