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

173
Views
¿Cómo cambiar la posición de las imágenes clonadas con un script?

Quiero clonar una imagen y cambiar la posición de la copia clonada. Estoy clonando con el siguiente script que sigue una imagen definida en el documento:

 window.onload = function () { var div = document.getElementById('autumn1'); var img = new Image(); img.src = 'autumn-leaves-hd-png--3101.png'; div.appendChild(img); img.height = window.innerHeight / 6; img.width = window.innerWidth / 6; function cloneImg() { div.appendChild(img.cloneNode(true)); } for (let index = 0; index < 4; index++) { cloneImg(); img.forEach(img.X = Math.random()); } }

¿Cómo puedo introducir el cambio de posición de la imagen clonada en el script anterior?

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

0

Puede devolver el elemento de imagen en la función.

Por favor, vea el fragmento a continuación:

 window.onload = function () { var div = document.getElementById('autumn1'); var img = new Image(); img.src = 'https://www.gravatar.com/avatar/bef07ce752c0e44449f4ec791d752871?s=48&d=identicon&r=PG&f=1'; div.appendChild(img); img.height = window.innerHeight / 6; img.width = window.innerWidth / 6; function cloneImg() { return div.appendChild(img.cloneNode(true)); } for (let index = 0; index < 4; index++) { let clone = cloneImg(); let random = Math.random()*75; clone.style.position = 'absolute' clone.style.left = random + "%"; } }
 <div id="autumn1"></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!