Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prototype.js: reset setStyle

Is there's any way how to reset styles back to what's in my CSS?

Example:

#foo {width: 50px; height: 50px; position: absolute; top: 150px; left: 250px;}


function moveFoo(newpostop, newposleft){
  $('foo').setStyle({top: newpostop+'px', left: newposleft+'px'});
}

Now when I'm done with it, I'd like to move foo back when it was. I know it can be hard-coded, but I need to do this with 25 different divs.

Thanks

like image 992
jack moore Avatar asked Feb 25 '10 03:02

jack moore


1 Answers

Setting a style with a null-value does the trick with unsetting in prototype.js

So you can also use $('foo').setStyle({top:null,left:null}) to revert the changes you did.

like image 182
heiglandreas Avatar answered Sep 20 '22 02:09

heiglandreas