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

92
Views
I want to change image 1 to image 2 if it's clicked then return to image 1 automatically after 1 second

When the image is clicked, I want it to change to another image and get pushed to the top

After it's clicked and image 2 appears it returns back to image 1 and get pushed back to the bottom

this is my code so far

function marioAnimation() {
  var i = true;
  var image = document.getElementById("mario1");
  if (i) {
    document.getElementById("mario1").src = "/mario2.png";
    image.style.marginTop = '10px';
    var x = false;
  } else {
    document.getElementById("mario1").src = "/mario1.png";
  }
}
<section id="section1">
  <div class="container">
    <img class="image" src="/mario1.png" alt="" id="mario1" onclick="marioAnimation()" style="margin-top: 50px;">

  </div>
</section>

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!