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

80
Views
How to insertAdjacentHTML between 2 different divs

I need to get my div between 2 divs inside my template. I can only edit it with external HTML, JS. Template looks like this:

<main id="content-in">
    <div id="homepage-banner"> XXX </div>
    <div id="carousel-banner"> XXX </div>

And I need to get my img and a href <div id="moveOut"> XXX </div> between these 2.

I have it like this now which works ok:

<script>
function addCode() {
    var d1 = document.getElementById('content-in');
    d1.insertAdjacentHTML('afterbegin', '<div id="moveOut"><a href="https://example.com/"><img src="https://example.png" alt=""></a></div>');
        }
</script>

but I need to move it. Thank you for your help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to insert after the homepage-banner DIV.

var d1 = document.getElementById("homepage-banner");
d1.insertAdjacentHTML('afterend', '<div id="moveOut"><a href="https://example.com/"><img src="https://example.png" alt=""></a></div>');
about 4 years ago · Juan Pablo Isaza Report
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!