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

93
Views
Javascript - change div after page load

I have a div that renders automatically by a plugin, I want after the page has loaded, I can cut it from a place and put it inside the div that contains my image:

to exemplify I made this codepen, I want to change the div 'change-place' into the div 'contain-image'

Code pen

in short I want to make a javascript that takes the blue div out of the red one and puts it inside the green one

$(document).ready(function() {
        $('.contain-image').append($('.change-place'));
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your code works ... you have to add:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

If you want to use Vanilla JS code I upload this example.

window.addEventListener("load", myFunc);

function myFunc() {
    let el = document.querySelector('.change-place');
    document.querySelector('.contain-image').appendChild(el);
};
.contain-image {
    width: 500px;
    height: 300px;
    background: #00ff00;
    display: inline-flex;
}

.minha-imagem {
    width: 200px;
    height: 200px;
}

.dolado {
    width: 500px;
    height: 300px;
    background: #ff0000;
    display: inline-flex;
}

.change-place {
    width: 100px;
    height: 100px;
    background: #0000ff;
    display: inline-flex;
    color: #fff;
}
<div class='contain-image'>
    <div>
        <h1>contem titulo</h1>
    </div>
    <div><img class="minha-imagem" alt="" src="" /></div>
    <div><button>botão</button></div>
</div>
<div class="dolado">
    <div class='change-place'>teste</div>
</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!