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

114
Visualizações
How to manipulate HTML elements in a string using JavaScript?

I have a variable called with a description.

var description = "<p>There are two 9-inch (228mm) lights available, a spread beam driving light and a pencil beam spot light, both are high-powered. The driving light provides over 460 metres @ 1 Lux, while the spot light covers 900 metres @ 1 Lux meaning a driving / spot combo is producing some serious light on the road. But, as they are sold in mix and match kits, or individually, you can bias your purchase to maximum distance or serious spread.</p>
<table style="height: 299px; width: 584px;" width="584" align="center">
<tbody>
  <tr style="height: 23px;">
    <td style="width: 276.469px; height: 23px;">&nbsp;</td>
    <td style="width: 291.531px; height: 23px;"><strong>PIR91145S</strong></td>
  </tr>
  <tr style="height: 23px;">
    <td style="width: 276.469px; height: 23px;"><strong>Waterproof rate</strong></td>
    <td style="width: 291.531px; height: 23px;">IP67</td>
  </tr>
  <tr style="height: 23px;">
    <td style="width: 276.469px; height: 23px;"><strong>Product dimension</strong></td>
    <td style="width: 291.531px; height: 23px;">ф228.6*86.7mm</td>
  </tr>
  <tr style="height: 23px;">
    <td style="width: 276.469px; height: 23px;"><strong>LED Type</strong></td>
    <td style="width: 291.531px; height: 23px;">OSRAM</td>
  </tr>
  <tr style="height: 23px;">
    <td style="width: 276.469px; height: 23px;"><strong>Effective Lumen</strong></td>
    <td style="width: 291.531px; height: 23px;">10485 LM</td>
  </tr>
</tbody>
</table>
<img src="" id="" name="">";

Now I am trying to remove table element and image elements with the following code:

  data.data.description.replace(/<img[^>]*>/g, '').replace(/<table[^>]*>/g, '')

It do remove the table and image element but it still display something like this:

<strong>Waterproof rate</strong>" IP67 " etc.....

how is it possible to remove completely the table element and the elements inside the table?. thanks.

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