Register Now


Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Jquery Animation Ball

Jquery Animation Ball is to form a bouncing ball animation impact mistreatment jQuery. simply a fast fun post. This animation impact is made supported totally different parameters just like the bouncing count, speed and etc. in an exceedingly previous tutorial, we’ve got seen additional samples of operating with jQuery. for instance, jQuery background animation on page scroll, jQuery optical phenomenon slider and additional.

jQuery is a popular JavaScript library that can be used to create various types of animations, including a bouncing ball . To create a bouncing ball using jQuery, you will need to use some basic jQuery functions such as animate(), setInterval(), and css().

Here’s an example of how you could create a simple bouncing ball using jQuery:

  var ball = $("#ball"); // select the ball element
  var x = 0; // initial x position
  var y = 0; // initial y position
  var xSpeed = 5; // x speed
  var ySpeed = 5; // y speed
    // move the ball
    x += xSpeed;
    y += ySpeed;
    ball.css({left: x, top: y});
    // check for collisions with the edges of the screen
    if(x + ball.width() > $(window).width() || x < 0){
      xSpeed = -xSpeed;
    if(y + ball.height() > $(window).height() || y < 0){
      ySpeed = -ySpeed;
  }, 30); // run the animation every 30 milliseconds

In this example, the ball is defined as an element with an ID of “ball” in the HTML. The script uses the setInterval() function to repeatedly update the position of the ball and check for collisions with the edges of the screen. The ball’s position is updated using the css() function, which changes the left and top CSS properties of the ball element.

You can further customize the animation by adjusting the speed of the ball, the size of the ball and the color of the ball. And also you can use the animate() function of jQuery to make more complex animation of the ball.

Leave a reply