jquery点击向右,点击向左

  
    
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>webrx-title</title>
  6. <script src="js/jquery-1.11.2.min.js"></script>
  7. <style>
  8. #iii{
  9. display:block;
  10. position:absolute;
  11. }
  12. </style>
  13. <script>
  14. $(document).ready(function(e) {
  15. function aa(){
  16. var pos= $('#iii').position();
  17. if(pos.left==200){
  18. $('#iii').animate({left:0},'fast');
  19. }else{
  20. $('#iii').animate({left:200},'fast');
  21. }
  22. }
  23. $('.left').click(aa);
  24. setInterval(aa,1000);
  25. });
  26. </script>
  27. </head>
  28. <body>
  29. <input type="button" value="right--200" class="left">
  30. <img src="images/flower.jpg" id="iii" width="120">
  31. </body>
  32. </html>
id 一定要用position:absoult;




你可能感兴趣的:(jquery)