【发布时间】:2012-10-16 21:22:42
【问题描述】:
我在使用 switchClass 方法时遇到了一些问题。
当鼠标悬停在类newsArea 时,我想添加/删除一个css类(newsHover)并进行一些转换。
我有以下代码
$('.newsArea').mouseover(function(){
$(this).switchClass('','newsHover',500, 'linear');
}).mouseleave(function(){
$(this).switchClass('newsHover','',500);
});
我认为这些方法是正确的,如您所见: http://docs.jquery.com/UI/Effects/ClassTransitions 和 http://jqueryui.com/docs/switchClass/
newsHover 类有一个背景图片:
.newsHover{
background-image: url("../../images/newsArea-hover.png");
background-repeat: no-repeat;
background-position:left top;
width: 200px; height: 52px;
}
图像出现但没有任何过渡。它在 500 毫秒后出现。
我可以接受任何使用 css3 跨浏览器的解决方案。
这里有什么提示吗??
谢谢
编辑
我忘了告诉我我使用的是 1.7.2 jquery 版本; jquery.easing.1.3 和 jquery-ui-1.8.23.custom.min(选择了所有组件)
【问题讨论】:
-
谢谢。但是 addClass() 和 removeClass 方法我不能有任何转换,对吧??还是我忘记了什么??
标签: jquery background jquery-animate css-transitions toggleclass