Advertisement
consolatio

animate jquery

Jul 29th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. .button{
  5. border:1px solid black;
  6. text-align:center;
  7. position:absolute;
  8. left:500px;
  9. top:400px;
  10. width:100px;
  11. height:100px;
  12. }
  13. .box{
  14. position:absolute;
  15. left:100px;
  16. top:100px;
  17. width:250px;
  18. height:250px;
  19. border:1px solid black;
  20. -webkit-transform:rotate(45deg);
  21. }
  22. </style>
  23. <script src="jquery.js"></script>
  24. <script>
  25. var x=100;
  26. var y=100;
  27. $(document).ready(function(){
  28. $(".button").click(function(){
  29. y+=50;
  30. $(".box").animate({top:y},1000);
  31. });
  32.  
  33. $(".button").hover(function(){
  34. $(".button").animate({background:"yellow",width:"150px",height:"150px",left:"475px",top:"375px"},1000);
  35. });
  36.  
  37. $(".button").mouseout(function(){
  38. $(".button").animate({background:"white",width:"100px",height:"100px",left:"500px",top:"400px"},1000);
  39. });
  40.  
  41. $(".box").click(function(){
  42. x=100;
  43. y=100;
  44. $(".box").animate({left:x,top:y},1000);
  45. });
  46. });
  47. </script>
  48. </head>
  49. <body>
  50. <div class="button">
  51. Click Me
  52. </div>
  53. <div class="box">
  54. </div>
  55. </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement