$( document ).ready(function() { count = 1; windowWidth = $(window).width(); windowHeight = $(window).height(); setInterval(function () { pos = Math.floor((Math.random() * windowWidth) + 1); delay = Math.floor((Math.random() * 100) + 1); $("body").append("
"); setTimeout(function(){ $( ".new" ).css("top",windowHeight).removeClass("new"); },delay); count ++; }, 1); });