我想将我的 CSS 转换转换为 Jquery
我的 CSS 转换是这样的:
.classname {
width : 470px;
transition: all 2s ease 0s;
}
.classname:hover {
width : 700px;
}
这意味着 CSS 代码,改变了元素的宽度。
那么,我如何使用 Jquery 做到这一点?
最佳答案
您需要做的就是在您的类上添加一个事件,然后将动画方法附加到它。你可以看到这些 learn.jquery.com 的例子
$(".classname").on({
mouseenter : function(){
$(this).animate({
width : 700
});
},
mouseleave : function(){
$(this).animate({
width : 470
});
}
});
jsfiddle:http://jsfiddle.net/w5pRy/1/
关于jquery - 将 CSS 过渡转换为 Jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21429422/