Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda