I want to move button left-right and right-left using jquery

前端 未结 5 1333
执笔经年
执笔经年 2021-01-24 06:11

I am able to move button to left side but after that how i can again move it to right side. Can i also use delay here.

Here is the code that i have tried:



        
5条回答
  •  失恋的感觉
    2021-01-24 06:48

    Yes, the animate function takes a function that is called after the animation is complete. So you can do:

     $(document).ready(function () {
          example_animate(100);
      });
    
      function example_animate(px) {   
         $('#Button1').animate({
             'marginLeft': px
         }, function(){
           $('#Button1').animate({
             'marginLeft': 1
           });
         });
     }
    

    http://jsbin.com/ixajol/1/edit

提交回复
热议问题