jQuery Callback 函数

Callback 函数在当前动画 100% 完成之后执行。
$("p").hide(1000,function(){
alert("The paragraph is now hidden");
});

<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Jquery Test</title>
<script type="text/javascript" src="../js/jquery-2.1.0.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#start").click(function(){
$("p").animate({left:'1250px'},1000,function(){
$("p").text("moved");
});
}); 
$("#stop").click(function(){
$("p").stop();
}); 
});
</script>
</head>

<body>
<h2 class= "h2">This is a heading</h2>
<button type="button" id="start">start</button>
<button type="button" id="stop">stop</button>
<p style="position:absolute;color:red">hello</p> 
</body>
</html>


jQuery - Chaining

通过 jQuery,您可以把动作/方法链接起来。

Chaining 允许我们在一条语句中允许多个 jQuery 方法(在相同的元素上)。

下面的例子把 css(), slideUp(), and slideDown() 链接在一起。"p1" 元素首先会变为红色,然后向上滑动,然后向下滑动:

$("#p1").css("color","red").slideUp(2000).slideDown(2000);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值