Guest User

Untitled

a guest
Apr 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. function Ball(f) {
  12. var el = document.createElement('div');
  13. var farge = ['red', 'blue', 'green'];
  14. el.style.backgroundColor = farge[f];
  15. el.style.width = '60px';
  16. el.style.height = '60px';
  17. el.style.borderRadius = '30px';
  18. el.style.position = 'fixed';
  19.  
  20. document.body.appendChild(el);
  21.  
  22. el.posisjon = function (x, y) {
  23. el.style.left = x;
  24. el.style.top = y;
  25. };
  26.  
  27. return el;
  28. }
  29. var nr = Math.floor(Math.random() * 3);
  30. var ball = Ball(nr);
  31. var x = Math.random() * 80 + '%';
  32. var y = Math.random() * 80 + '%';
  33. ball.posisjon(x, y);
  34. </script>
  35.  
  36.  
  37.  
  38. <script id="jsbin-source-javascript" type="text/javascript">function Ball(f) {
  39. var el = document.createElement('div');
  40. var farge = ['red', 'blue', 'green'];
  41. el.style.backgroundColor = farge[f];
  42. el.style.width = '60px';
  43. el.style.height = '60px';
  44. el.style.borderRadius = '30px';
  45. el.style.position = 'fixed';
  46.  
  47. document.body.appendChild(el);
  48.  
  49. el.posisjon = function (x, y) {
  50. el.style.left = x;
  51. el.style.top = y;
  52. };
  53.  
  54. return el;
  55. }
  56. var nr = Math.floor(Math.random() * 3);
  57. var ball = Ball(nr);
  58. var x = Math.random() * 80 + '%';
  59. var y = Math.random() * 80 + '%';
  60. ball.posisjon(x, y);</script></body>
  61. </html>
Add Comment
Please, Sign In to add comment