Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <script src="https://ajax.googleapis.com/.../jquery/3.3.1/jquery.min.js"> </script>
- <body>
- <div id = "txt">
- </div>
- </body>
- <script type = "text/javascript">
- var div = document.getElementById("txt");
- var br = document.createElement("br");
- var x = document.createElement("input");
- x.setAttribute("type", "number");
- x.setAttribute("id", "x");
- var para = document.createTextNode("X:");
- div.appendChild(para);
- div.appendChild(x);
- div.appendChild(br);
- var y = document.createElement("input");
- y.setAttribute("type", "number");
- y.setAttribute("id", "y");
- var para = document.createTextNode("Y:");
- div.appendChild(para);
- div.appendChild(y);
- var br1 = document.createElement("br");
- div.appendChild(br1);
- var z = document.createElement("input");
- z.setAttribute("type", "number");
- z.setAttribute("id", "rotate");
- var para = document.createTextNode("Rotacija:");
- div.appendChild(para);
- div.appendChild(z);
- var br2 = document.createElement("br");
- div.appendChild(br2);
- var btn1 = document.createElement("button");
- btn1.innerHTML = "To Json";
- btn1.setAttribute("id", "json");
- div.appendChild(btn1);
- var br3 = document.createElement("br");
- div.appendChild(br3);
- var btn2 = document.createElement("button");
- btn2.innerHTML = "Animate";
- btn2.setAttribute("id", "animate");
- div.appendChild(btn2);
- var br4 = document.createElement("br");
- div.appendChild(br4);
- var nov = document.createElement("div");
- nov.setAttribute("id", "dvizi");
- nov.setAttribute("style", "height: 50px; width: 50px; background-color: yellow; position: absolute");
- div.appendChild(nov);
- $(document).ready(function(){
- $("#animate").click(function(){
- var x=document.getElementById("x").value;
- var y=document.getElementById("y").value;
- $("#dvizi").animate({
- left:"+="+x,
- top:"-="+y
- });
- });
- $("#animate").click(function(){
- var rot = document.getElementById("rotate").value;
- $("#dvizi").css("transform", "rotate(" + rot + "deg)");
- });
- });
- $(document).ready(function(){
- $("#json").click(function(){
- var obj = new Object();
- obj.x = document.getElementById("x").value;
- obj.y = document.getElementById("y").value;
- obj.rot = document.getElementById("rotate").value;
- var str = JSON.stringify(obj);
- console.log(str);
- });
- });
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement