• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Jelon_Jang
博客园    首页    新随笔    联系   管理    订阅  订阅

关于jQuery中的事件和动画

在学习jQuery中,碰到一点个人认为比较难理解的知识,在这里拿出来看一下:

 1 $("#panel").hover(function() {
 2    $(this).stop.animate({ // 如果在此时触发了光标移出的事件
 3        height: "150"      // 将执行下面的动画
 4                           // 而非光标移出事件中的动画
 5     },  200).animate({
 6        width: "300"
 7     }, "300") 
 8 }, function() {           // 以下是光标移出事件的动画代码段,将不会被执行
 9    $(this).stop.animate({
10         height: "22"
11     }, 200).animate({
12         width: "60"
13     }, 300) 
14 })

解决方法:

 1 $("#panel").hover(function(true) {  // 函数第一个参数设置为true
 2     $(this).stop.animate({
 3          height: "150"     
 4                       
 5     },  200).animate({
 6          width: "300"
 7     }, "300") 
 8 }, function(true) {        
 9     $(this).stop.animate({
10         height: "22"
11     }, 200).animate({
12         width: "60"
13      }, 300) 
14 })

 

 

posted @ 2013-01-22 14:46  Jelon_Jang  阅读(86)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3