Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4.  
  5. <title>jQuery Module</title>
  6. <!-- <link rel="stylesheet" type="text/css" href="index.css"> -->
  7. <script type="text/javascript" src="jquery-3.3.1.js"></script>
  8.  
  9. <style type="text/css">
  10.  
  11. *{
  12.  
  13. margin:0;
  14. padding:0;
  15. box-sizing: border-box;
  16. }
  17.  
  18. #main-iframe{
  19.  
  20. width: 600px;
  21. height: 600px;
  22. }
  23.  
  24.  
  25.  
  26. .green-circle{
  27.  
  28. margin: 40px;
  29. width: 150px;
  30. height: 150px;
  31. border: 2px solid black;
  32. border-radius: 50%;
  33. background-color: green;
  34. }
  35.  
  36.  
  37. .red-square{
  38.  
  39. margin: 40px;
  40. width: 150px;
  41. height: 150px;
  42. border: 2px solid black;
  43. background-color: red;
  44. }
  45.  
  46. </style>
  47.  
  48. </head>
  49.  
  50.  
  51. <body>
  52.  
  53. <div class="green-circle"></div>
  54. <p class="circle-colour"></p>
  55. <div class="green-circle"></div>
  56. <p class="circle-colour"></p>
  57.  
  58. <script type="text/javascript">
  59.  
  60. function randomColour(){
  61.  
  62. var hexArray = '0123456789ABCDEF';
  63. var colour = '#';
  64.  
  65. for (var i=0; i<6; i++){
  66.  
  67. colour += hexArray[Math.floor((Math.random() * 16))];
  68. }
  69.  
  70. return colour;
  71. }
  72.  
  73. /* $("#fading-button").click(function(){
  74.  
  75. if ($("#fading-text").css("display") == "none"){
  76.  
  77. $("#fading-text").fadeIn(1200);
  78. }
  79. else{
  80. $("#fading-text").fadeOut(1200);
  81. }
  82. }) */
  83.  
  84. $(".green-circle").click(function(){
  85.  
  86. $(this).css("background-color", randomColour());
  87.  
  88. $(this).animate({
  89. width:"400px",
  90. height:"400px",
  91. marginLeft: "600px",
  92. marginTop: "350px"
  93. }, 2000, function(){
  94.  
  95. console.log("Callback function started.");
  96.  
  97. $(this).animate({
  98. width:"150px",
  99. height:"150px",
  100. marginLeft: "40px",
  101. marginTop: "40px"
  102. }, 2000);
  103.  
  104. console.log("Callback function ended.");
  105. });
  106.  
  107. $(this).fadeOut(1200, function(){
  108.  
  109. console.log("Fade out function started.");
  110. $(this).css("background-color", randomColour());
  111. });
  112.  
  113. $(this).fadeIn(1200);
  114. console.log("Fade In function started.");
  115.  
  116. })
  117.  
  118. </script>
  119.  
  120. </body>
  121.  
  122. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement