jquery 的animate()方法不可以改变背景颜色及字体颜色 JS

shuke 2018-5-4 1941

jquery animate函数不能处理背景色渐变,需要使用jquery.color插件    

文件地址:在下边

代码效果如下:

// animate({params},speed,callback)
// 如果 params 中的数据有toggle,说明该属性的效果会从有到无,再次触发时会从无到有
$("#box").get(0).style.marginLeft
$("#btns button:nth-child(1)").click(function (res) {
// 动画支持链接(动画可以拼在一起)
    $("#box").animate({
        "marginLeft":"30px",
        "opacity":"0.5",
        "backgroundColor":"#00ff00",
        "color":"red"
//        "height":"toggle"
    },3000).delay(5000);
//    动画支持队列功能(不会出现阻塞的动画)
    $("#box").animate({
        "marginLeft":"200px",
        "opacity":"0.9",
        "height":"300px",
        "display":"block"
    },3000);
})
$("#btns button:nth-child(2)").click(function (res) {
    $("#box").stop(false,true)
})

上传的附件:
最新回复 (0)
全部楼主
返回