Advertisement
Guest User

IPKS 2kol

a guest
Jan 17th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. <html>
  2.  
  3. <script src="https://ajax.googleapis.com/.../jquery/3.3.1/jquery.min.js"> </script>
  4. <body>
  5.  
  6. <div id = "txt">
  7. </div>
  8.  
  9. </body>
  10. <script type = "text/javascript">
  11.  
  12. var div = document.getElementById("txt");
  13. var br = document.createElement("br");
  14.  
  15. var x = document.createElement("input");
  16. x.setAttribute("type", "number");
  17. x.setAttribute("id", "x");
  18. var para = document.createTextNode("X:");
  19. div.appendChild(para);
  20. div.appendChild(x);
  21.  
  22. div.appendChild(br);
  23.  
  24. var y = document.createElement("input");
  25. y.setAttribute("type", "number");
  26. y.setAttribute("id", "y");
  27. var para = document.createTextNode("Y:");
  28. div.appendChild(para);
  29. div.appendChild(y);
  30.  
  31. var br1 = document.createElement("br");
  32. div.appendChild(br1);
  33.  
  34. var z = document.createElement("input");
  35. z.setAttribute("type", "number");
  36. z.setAttribute("id", "rotate");
  37. var para = document.createTextNode("Rotacija:");
  38. div.appendChild(para);
  39. div.appendChild(z);
  40.  
  41. var br2 = document.createElement("br");
  42. div.appendChild(br2);
  43.  
  44. var btn1 = document.createElement("button");
  45. btn1.innerHTML = "To Json";
  46. btn1.setAttribute("id", "json");
  47. div.appendChild(btn1);
  48.  
  49. var br3 = document.createElement("br");
  50. div.appendChild(br3);
  51.  
  52. var btn2 = document.createElement("button");
  53. btn2.innerHTML = "Animate";
  54. btn2.setAttribute("id", "animate");
  55. div.appendChild(btn2);
  56.  
  57. var br4 = document.createElement("br");
  58. div.appendChild(br4);
  59.  
  60. var nov = document.createElement("div");
  61. nov.setAttribute("id", "dvizi");
  62. nov.setAttribute("style", "height: 50px; width: 50px; background-color: yellow; position: absolute");
  63. div.appendChild(nov);
  64.  
  65. $(document).ready(function(){
  66. $("#animate").click(function(){
  67. var x=document.getElementById("x").value;
  68. var y=document.getElementById("y").value;
  69.  
  70. $("#dvizi").animate({
  71. left:"+="+x,
  72. top:"-="+y
  73. });
  74.  
  75. });
  76. $("#animate").click(function(){
  77.  
  78. var rot = document.getElementById("rotate").value;
  79.  
  80. $("#dvizi").css("transform", "rotate(" + rot + "deg)");
  81.  
  82. });
  83. });
  84. $(document).ready(function(){
  85.  
  86. $("#json").click(function(){
  87.  
  88. var obj = new Object();
  89. obj.x = document.getElementById("x").value;
  90. obj.y = document.getElementById("y").value;
  91. obj.rot = document.getElementById("rotate").value;
  92. var str = JSON.stringify(obj);
  93. console.log(str);
  94. });
  95.  
  96. });
  97.  
  98. </script>
  99.  
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement