我正在使用switchClass(使用UI)来更改元素上的类。
如此处所定义 - http://jqueryui.com/demos/switchClass/ - 方法
switchClass( remove, add, [duration] )
我可以使用某种选择器来不必规定需要删除的类吗?
像...一样的东西。
switchClass( '*', 'newclass', slow )
我最初把这样的一切都链接起来......
$('body').removeClass().addClass('newClass')
但是在类之间打破了我的动画。
解决
在我的情况下,我能够使用
animate({ backgroundColor: target_colour }, 500)
而不是改变班级......
如果有人知道怎么做switchClass魔术,我相信它会派上用场!
答案 0 :(得分:3)
$('body').switchClass( $('body').attr('className'), 'newclass', 'slow' )
)