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

237
Vistas
Delete tag attributes from html String in Javascript

i am using Puppeteer to get 2 tables from a web.

I save that tables in 2 separate Strings, but now i want to delete all id, classes and style attributes from all tags inside the table. But i can't figure how to, is there a way i can work with a string like if its html ?

This is a sample of the table i would get:

    <table id="xxxxx" class="aaaaa" role="ssssss">
  <tbody>
    <tr class="ui-widget-content" role="row">
      <td role="gridcell" class="ui-panelgrid-cell summaryPanelHeaderColumn">Hello</td>
      <td role="gridcell" class="ui-panelgrid-cell summaryPanelColumn">
        <table>
          <tbody>
            <tr>
              <td class="rhthtyhyj">
                <label style="display: block;">Hello text sample</label>
              </td>
              <td class="rwhgthyjy">
                <button id="u6krkrik" name="j_idt111:0:j_idt124:0:j_idt129" class="ertjyjuejujm" onclick="wethyjyj.bcn(this,event,[function(event){rtyjeyjeuk.ab({s:&quot;jetrjyrjyj1:0:ryejyjy:0:j_idt129&quot;,e:&quot;click&quot;,p:&quot;j_idt111:0:j_idt124:0:j_idt129&quot;,u:&quot;ethtehth driveSummaryFieldSet&quot;});},function(event){PrimeFaces.ab({s:&quot;j_idt111:0:j_idt124:0:j_idt129&quot;});return false;}]);" type="submit" role="button" aria-disabled="false">
                  <span class="ui-button-icon-left ui-icon ui-c ui-icon-closethick"></span>
                  <span class="ui-button-text ui-c">Again A sample text</span>
                </button>
              </td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

And this is the sample of what i would like to get when cleaning the table:

    <table>
  <tbody>
    <tr>
      <td>Hello</td>
      <td>
        <table>
          <tbody>
            <tr>
              <td>
                <label>Hello text sample</label>
              </td>
              <td>
                <button>
                  <span></span>
                  <span>Again A sample text</span>
                </button>
              </td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

Just cleaning the tags attributes, and keep only raw tags and text inside

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