2013-03-18 189 views
0

我知道这可能会作为重复被关闭,但我仍然无法找到所有类似问题中的问题的答案。jQuery - 悬停动画

我想animate()我的页面上的元素(通过jQuery,你猜对了)鼠标悬停。我所做的是:

$('blockquote').hover(function() { 
    console.log($(this)); 
    $(this).animate({textSize: '+=10px'}, 500); 
}, function() { 
    $(this).animate({textSize: '-=10px'}, 500); 
}); 

console.log记录此:

[blockquote#daily_quote, context: blockquote#daily_quote, jquery: "1.9.1", constructor: function, init: function, selector: ""…] 

hover这两个函数被调用,$(this)得到记录,但没有动画。

+0

确实TEXTSIZE真的存在... ???如果不是,则使用fontSize。 – 2013-03-18 11:36:48

+0

什么是blockquote?它是指班级还是其他任何东西? – 2013-03-18 11:46:21

回答

5

使用fontSize

$('blockquote').hover(function() { 
    // console.log($(this)); 
    $(this).animate({fontSize: '+=10px'}, 500); 
}, function() { 
    $(this).animate({fontSize: '-=10px'}, 500); 
}); 
+0

好的,这解决了这个问题,但是如果我尝试更改''background-color''属性,它不会再起作用... – whatyouhide 2013-03-18 11:39:27

+0

@whatyouhide只使用背景属性 – sasi 2013-03-18 11:39:59

+0

@whatyouhide如果要为动画颜色添加动画, jQuery UI。 – undefined 2013-03-18 11:42:02

1
This may be help you. 
$('blockquote').hover(function() { 

     $(this).animate({left: '+=10px'}, 700); 
    }, function() { 
     $(this).animate({left: '-=10px'}, 700); 
    }); 

你可以使用任何属性,而不是留下