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

225
Views
How can I change th attribute rowspan using js

I have this tag:

<th id="empty-span" class="empty-span" colspan="15" rowspan="5">

and after I click on a button I want to have

<th id="empty-span" class="empty-span" colspan="15" rowspan="6">

how can I do it using js?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

You can do it simply by getting the element then changing the rowSpan proprety

document.getElementById("empty-span").rowSpan = "6";

Or with jquery :

$('#empty-span').attr('rowspan', '6');
about 4 years ago · Santiago Trujillo Report

0

Try this :

document.getElementById("empty-span").rowSpan = "6";

Or: with incremental :

var currentNode = document.getElementById("empty-span");
currentNode.rowSpan = parseInt(currentNode.rowSpan) + 1;
about 4 years ago · Santiago Trujillo Report

0

You can change the rowSpan using element.rowSpan.

To demonstrate, click on the first cell to change the rowSpan to 2;

function enlarge() {
  event.target.rowSpan = 2;
}
table, th, td {
    border: 1px solid;
}
<table>
    <tr>
        <td onclick='enlarge()'>Click me to enlarge!</td>
        <td>#1-1</td>
        <td>#1-2</td>
    </tr>
    <tr>
        <td>#2-1</td>
        <td>#2-2</td>
    </tr>
<table>

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!