Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. (function makeDiv(){
  2. var divsize = ((Math.random()*100) + 50).toFixed();
  3. var color = '#'+ Math.round(0xffffff * Math.random()).toString(16);
  4. $newdiv = $('<div/>').css({
  5. 'width':divsize+'px',
  6. 'height':divsize+'px',
  7. 'background-color': color
  8. });
  9.  
  10. var posx = (Math.random() * ($(document).width() - divsize)).toFixed();
  11. var posy = (Math.random() * ($(document).height() - divsize)).toFixed();
  12.  
  13. $newdiv.css({
  14. 'position':'absolute',
  15. 'left':posx+'px',
  16. 'top':posy+'px',
  17. 'display':'none'
  18. }).appendTo( 'body' ).fadeIn(100).delay(300).fadeOut(200, function(){
  19. $(this).remove();
  20. makeDiv();
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement