在下面的代码中,click()中的animate()函数起作用。但是,mouseenter()中的animate()或pulse() (未注释时)也不起作用。pulse()函数是由Jarrod提供的。
http://jarrodoverson.com/static/demos/jquery.pulse.html
sectionTitle = $j(this).find(".sectionTitle");
sectionTitle.click(function(){
if($j(this).parent().height() == sections[$j(this).parent().attr("id")]["height"]){
origHeight = sections[$j(this).parent().attr("id")]["origHeight"];
$j(this).parent().animate({height:origHeight},"slow");
}else{
height = sections[$j(this).parent().attr("id")]["height"];
$j(this).parent().animate({height:height},"slow");
}
})
sectionTitle.mouseenter(function(){
var properties = { "color" : '#F00' };
// $j(this).pulse(properties, 500, 3);
$j(this).animate({"background-color":'#F00'},"slow");
})下面是我的代码的一个活生生的例子。http://fantasticvisions.net/test/me/
上面页面上的许多H2元素都应用了classs sectionTitle。单击它们将使用jQuery animate()展开内容。但是,mouseenter()失败。
这里我漏掉了什么?我已经尝试了许多其他的变体,但都不起作用。mouseenter()事件确实会触发,并执行代码(我已经跟踪到了这一点),但效果似乎从未发生过。
发布于 2012-04-07 04:55:43
.animate()不工作,因为jQuery本身不支持颜色动画。
如果你包含jQuery UI或者一个彩色动画插件,这应该是可行的。
https://stackoverflow.com/questions/10048867
复制相似问题