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

115
Vistas
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 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