Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

227
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda