Edwin Edwin - 5 months ago 9
jQuery Question

How to make a DIV pop out from nowhere Jquery?

So I have a game where I want to show two numbers. But I want these numbers to come out from nowhere, perhaps from the button of the screen and they travel up and then disappear.

I was looking through the Jquery website, but I couldn't find anything similar.

Answer

Heres an example that i just wrote:

$(document).ready(function() {
  $("button").click(function(){
    $('.count').html(parseInt($('.count').html())+1);

    //allow time for animation to finish before next click
    $('button').hide();
    window.setTimeout(function(){$('button').show();},3000); 

    $("div").css("bottom","-20px");
    $("div").animate({bottom: '1200px'}, 2000);
  })
});

https://jsfiddle.net/xop36gcs/4/

Comments