欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jquery自定义动画

程序员文章站 2022-07-13 08:41:00
...

 

使用jquery实现自定义动画方法

   使用animate 实现动画 

css样式

//定义图片属性
img{position:relative;}//定位 

 

 

代码

$(function () {

          
//            $("img").hover(function () {
//
//                $(this).animate({left:"+=2px"},200).animate({left:"-=2px"},200);
//
//            }, function () {
//
//            });
            $("img").click(function () {

                $(this).animate({left:"+=3px"},200).animate({left:"-=3px"},200);

            });
            
        });

 

 

html代码

<img src="xxxx.jpg">

 

相关标签: jquery animate