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

153
Views
No se pueden establecer propiedades de indefinido (configuración 'izquierda')

Estoy tratando de mover la bola hacia la derecha, pero tengo este error: No se pueden establecer las propiedades de indefinido (configurando 'izquierda'). Traté de buscar, pero todas las respuestas dicen que mi código es correcto.

 var ballSpeed = 3; var ballPosition = 0; var ballTime = 1; var ball = $('#ball'); function bT() { ballPosition = ballPosition + ballSpeed; ball.style.left = ballPosition + "px"; } var ii =setInterval(bT, 1); console.log(ii);
 .window{ background-color: #00FFDD; height:100vh; margin: 0px; } #ball{ position: absolute; height: 100px; width: 100px; border-radius: 50%; background-color: red; }
 <!DOCTYPE html> <body> <div class="window"> <div id="ball"></div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="index.js" charset="utf-8"></script> </body> </html>

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

0

Usa esto en su lugar:

 var ballSpeed = 3; var ballPosition = 0; var ballTime = 1; var ball = $('#ball'); function bT() { ballPosition = ballPosition + ballSpeed; ball.css('left', ballPosition); } var ii =setInterval(bT, 1); console.log(ii);
 .window{ background-color: #00FFDD; height:100vh; margin: 0px; } #ball{ position: absolute; height: 100px; width: 100px; border-radius: 50%; background-color: red; }
 <!DOCTYPE html> <body> <div class="window"> <div id="ball"></div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="index.js" charset="utf-8"></script> </body> </html>

La modificación del estilo de un elemento de JQuery utiliza el método .css() , como se describe aquí.

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!