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

231
Views
¿Cómo giro continuamente una foto usando la función Javascript?

Estoy tratando de descubrir la lógica para rotar continuamente una imagen en Javascript. Hasta ahora he llegado a este código. img1 es la identificación de la imagen y hasta ahora funciona, pero solo gira una vez. ¿Cómo hago que gire cada vez que hago clic en él? Estoy usando el evento onclick .

 function rotateProfilePic() { var image = document.getElementById('img1'); image.style.transform = "rotate(180deg)"; }

Lo siento si la pregunta es demasiado simple para alguien, soy principiante en programación web.

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

0

Establezca su función como oyente de clics en la imagen:

 const imgTag = document.getElementById("img1"); const rotateStep = 180; // rotation size let curImgAngle = 0; function rotateProfilePic() { curImgAngle += rotateStep; imgTag.style.transform = `rotate(${curImgAngle}deg)`; } imgTag.addEventListener("click", rotateProfilePic);
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!