问题
Is there a way to animate in Jquery without specifying every property?
Lets, say:
.classA{
color:red;
}
.classB{
color:blue;
}
function animate(selector,classA,classB,time){
styles1 = $(classA).invented_get_styles();
styles2 = $(classB).invented_get_styles();
$(selector).animate(styles1,styles2,time);
}
Almost alll this syntax is invented but i think that what i am asking can be understood,
Is posible to animate from classes retrieving the styles (automated) and apply them instead of knowing (manual) the values? or if not, what's the best way..
回答1:
You can do it with jQueryUI/switchClass, you only need a custom build of jQueryUI with Effects Core enabled - nothing else, which is about 11k minified
Example
$( ".element_to_be_animated" ).switchClass( "oldClass", "newClass", 1000 );
来源:https://stackoverflow.com/questions/8023575/can-a-classa-styles-to-classb-styles-be-animated-easly