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

227
Views
Cambiar el color de la tabla dinámica en java
  1. las celdas de las dos diagonales sombreadas en naranja o chartreuse;
  2. con la celda de intersección de las diagonales sombreada en negro;
  3. y su texto en blanco

Hay una imagen aquí y así es como se supone que debe verse.

Así es como se supone que debe verse la tabla al final.

 function drawTable() { var rows = parseInt(document.getElementById("numRows").value); var cols = parseInt(document.getElementById("numColumns").value); var theHtmlCode = ""; theHtmlCode = "<table>"; theHtmlCode += "<tr>"; for ( var i=1 ; i<=cols ; i++ ) { theHtmlCode += "<th>"; theHtmlCode += "Column " + i; theHtmlCode += "</th>"; } theHtmlCode += "</tr>"; // create table rows for ( var j=1 ; j<=rows ; j++ ) { theHtmlCode += "<tr>"; // create table cells for ( var k=1 ; k<=cols ; k++ ) { if (k==j) { theHtmlCode += "<td class='across'>"; } else { theHtmlCode += "<td>"; } theHtmlCode += j + "." + k; theHtmlCode += "</td>"; } theHtmlCode += "</tr>"; } // close table tag theHtmlCode += "</table>"; document.getElementById("whereTheTableGoes").innerHTML = theHtmlCode; }
 body { background-color: lightblue} h1 {text-align: center} td { border: 2px blue solid} th { border: 3px red solid} img {border: 1px solid black} .across {background-color: pink} tr:nth-child(even) {background-color: #eb00ff;}
 <label>How Many Rows Do You Want in the Table?</label> <input type="number" min="1" id="numRows" placeholder="1 or more"> <br><br> <label>How Many Columns Do You Want in the Table?</label> <input type="number" min="1" id="numColumns" placeholder="1 or more"> <br><br> <button onclick="drawTable()">Click to Draw the Table</button><br><br> <div id="whereTheTableGoes"></div>

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!