Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!