原生js封装好的动画函数+jQuery函数animate




    
    Title
    


原生js方法:
封装好的js文件,只需调用startMove(obj,json,fn)这个函数
三个参数分别为:第一个:对象,id或者class等,第二个:json为属性值,
如width:200px,height:150px;可同时改变多个值;
fn为回调函数,执行其他的事情。

另外有特简洁的jQuery方法:4行代码可实现同样效果。。。
$(function () {
    $("#id").mouseenter(function () {
        $(this).animate({top: '25px', opacity: '30'}, 300, function () {
            $(this).css({width: "30px"});
            $(this).animate({top: '0', opacity: '10'}, 200)
        })
    })
});







你可能感兴趣的:(html,jquery,css,javascript)