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

314
Views
¿Por qué div.width no funciona cuando se usa clearInterval?

Hice un cuadrado que se mueve hasta el final del ancho de su contenedor usando set y clearInterval . Si agrego el ancho como un número, se detiene, pero cuando agrego container.width no funciona:

 var container = document.getElementById('container') var square = document.getElementById('mySquare') function theAll(sq,con){ var pos = 0; var moving = setInterval(move,10) function move(){ if(pos == con.width){ clearInterval(moving)} else{ pos++ sq.style.left=pos + "px";} }} theAll(square,container) #container{ font-size: 100%; font-family: Comic Sans MS; background-color: blanchedalmond; border-radius: 5px; padding: 0; width: 100%; height: 60%; display: flex; flex-direction: column; } #mySquare{ width: 5%; height: 5%; background-color: blueviolet; position: relative; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede intentar reemplazar con.width con con.offsetWidth

Ejemplo https://codepen.io/julien180/pen/JjJvqEd?editors=1111

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!