JQuery动画效果
2018-01-24 15:45
239 查看
1. 显示和隐藏
$(function() {
$(".show").click(function () {
$("#box").show(1000, function showNext () {
$(this).next().show(1000, showNext);
});
$(".hide").click(function () {
$("#box").hide(1000, function hideNext() {
$(this).next().hide(1000, hideNext);
});
$("#box").toggle(1000);
});
2. 上下滚动
$("#box").slideUp(1000);
$("#box").slideDown(1000);
$("#box").slideToggle(1000);
3. 淡入淡出
$("#box").fadeIn(1000);
$("#box").fadeOut(1000);
$("#box").fadeToggle(1000);
$("#box").fadeTo(1000, 0.33);
4. 自定义动画
$(function () {
$("#box").animate({
top: "+=100px",
left: "300px",
width: "300px",
height: "400px",
fontiSzie: "50px"
opacity: 0.5
}, 2000, function () {
alert("completed");
}); //同步动画
})
$("#box").animate({width: "300px"}).animate({opactiy: 0.5}); //连缀方式实现列队动画,仅支持在相同元素上。
$("#box").slideUp("slow").slideDown("slow").queue(function (next) {
$(this).css("color", "orange");
next(); //下面还要执行动画。
}).hide("slow");
$("#box").slideUp("slow").slideDown("slow").queue(function () {
$(this).css("color", "orange");
$(this).dequeue(); //下面还要执行动画。
}).hide("slow");
console.log($("#box").queue("fx").length); //列队动画长度
$("#box").clearQueue(); //清除动画
5. 停止动画
$("#stop").click(function () {
$("#box").stop(); //停止#box元素上的动画
})
$("#box").animate({left: "300px"}, 1000).animate({bottom: "300px"}, 1000).animate({with: "300px"}, 1000).animate({height: "300px"}, 1000);
$("#stop").click(function () {
$("#box").stop(true, true); //第一个true停止后面的动画, 第二个true停止后跳到末态位置。
})
$("#box").animate({left: "300px"}, 1000).delay(2000).animate({bottom: "300px"}, 1000).animate({with: "300px"}, 1000).animate({height: "300px"}, 1000);
//delay 2秒钟后执行后面动画
$("ani").click(function () {
$(":animated").css("color", "blue"); //查找正在运动的动画
})
6. 全局动画设置
$.interval = 5; //调整帧间隔时间
$.off = true; //关闭动画
$("#box").animate({left: "300px"}, 3000, "swing"); //缓动
$("#box").animate({left: "300px"}, 3000, "linear"); //匀速
$(function() {
$(".show").click(function () {
$("#box").show(1000, function showNext () {
$(this).next().show(1000, showNext);
});
$(".hide").click(function () {
$("#box").hide(1000, function hideNext() {
$(this).next().hide(1000, hideNext);
});
$("#box").toggle(1000);
});
2. 上下滚动
$("#box").slideUp(1000);
$("#box").slideDown(1000);
$("#box").slideToggle(1000);
3. 淡入淡出
$("#box").fadeIn(1000);
$("#box").fadeOut(1000);
$("#box").fadeToggle(1000);
$("#box").fadeTo(1000, 0.33);
4. 自定义动画
$(function () {
$("#box").animate({
top: "+=100px",
left: "300px",
width: "300px",
height: "400px",
fontiSzie: "50px"
opacity: 0.5
}, 2000, function () {
alert("completed");
}); //同步动画
})
$("#box").animate({width: "300px"}).animate({opactiy: 0.5}); //连缀方式实现列队动画,仅支持在相同元素上。
$("#box").slideUp("slow").slideDown("slow").queue(function (next) {
$(this).css("color", "orange");
next(); //下面还要执行动画。
}).hide("slow");
$("#box").slideUp("slow").slideDown("slow").queue(function () {
$(this).css("color", "orange");
$(this).dequeue(); //下面还要执行动画。
}).hide("slow");
console.log($("#box").queue("fx").length); //列队动画长度
$("#box").clearQueue(); //清除动画
5. 停止动画
$("#stop").click(function () {
$("#box").stop(); //停止#box元素上的动画
})
$("#box").animate({left: "300px"}, 1000).animate({bottom: "300px"}, 1000).animate({with: "300px"}, 1000).animate({height: "300px"}, 1000);
$("#stop").click(function () {
$("#box").stop(true, true); //第一个true停止后面的动画, 第二个true停止后跳到末态位置。
})
$("#box").animate({left: "300px"}, 1000).delay(2000).animate({bottom: "300px"}, 1000).animate({with: "300px"}, 1000).animate({height: "300px"}, 1000);
//delay 2秒钟后执行后面动画
$("ani").click(function () {
$(":animated").css("color", "blue"); //查找正在运动的动画
})
6. 全局动画设置
$.interval = 5; //调整帧间隔时间
$.off = true; //关闭动画
$("#box").animate({left: "300px"}, 3000, "swing"); //缓动
$("#box").animate({left: "300px"}, 3000, "linear"); //匀速
相关文章推荐
- jQuery 动画中 缓动效果的应用 (转)
- jQuery 动画效果,关键词 animate
- JQuery简单动画效果演示
- jQuery实现连续动画效果实例分析
- jquery实现动画菜单的左右滚动、渐变及图形背景滚动等效果
- jQuery 效果 - 动画
- jQuery中常用动画效果函数知识点整理
- 用js实现类似jquery里的animate动画效果
- jQuery实现动画效果的例子
- Jquery 动画效果 停止延迟
- 初学jQuery动画效果
- 让滚动条滚动到指定位置,带动画效果 jQuery
- 基于jquery的动画效果代码
- 一个CSS+jQuery实现的放大缩小动画效果
- jQuery实现带有洗牌效果的动画分页实例
- jQuery插件Slider Revolution实现响应动画滑动图片切换效果
- jQuery动画显示和隐藏效果实例演示(附demo源码下载)
- jQuery带动画效果的三级下拉菜单
- jQuery实现碰到边缘反弹的动画效果
- jQuery学习笔记之十一------动画效果