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

274
Views
Turn string into HTML document, remove element by class and then turn it back into HTML string?

I have a string containing HTML and I'm trying to remove a specific element from it. Right now I'm trying the following approach - I'm using const doc = new DOMParser().parseFromString(body, 'text/html'); to turn the string into HTML document and now I'm trying to somehow remove this element from the HTML document:

<a href="#/register" class="mx_ButtonParent mx_ButtonCreateAccount mx_Button_iconCreateAccount">
    <div class="mx_ButtonLabel">_t("Create Account")</div>
</a>

Then I'd want to turn it back into a string. I'm not quite sure how to both remove the element from the HTML document and then turn it back into a string.

<div class="mx_Parent">
    <a href="" target="_blank" rel="noopener">
        <img src="themes/img/logos/logo-letter.png" alt="" class="mx_Logo"/>
    </a>
    <h1 class="mx_Header_title">_t("Welcome to Test")</h1>
    <div class="mx_ButtonGroup">
        <div class="mx_ButtonRow">
            <a href="#/login" class="mx_ButtonParent mx_ButtonSignIn mx_Button_iconSignIn">
                <div class="mx_ButtonLabel">_t("Sign In")</div>
            </a>
            <a href="#/register" class="mx_ButtonParent mx_ButtonCreateAccount mx_Button_iconCreateAccount">
                <div class="mx_ButtonLabel">_t("Create Account")</div>
            </a>
        </div>
    </div>
</div>
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!