简体   繁体   中英

can a .classA styles to .classB styles be animated easly?

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..

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 );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM