tags:

views:

54

answers:

1

This is my original CSS for my #frame div.

....#frame{ position:relative; top:35px; }

Then, I use JQuery to change the CSS of my div...

$('#frame').css("position","absolute"); $('#frame').css("left",50);

Now, how do I clear all those changes, and revert back to normal?

+6  A: 

You can't without explicitly setting it back to the old property values.

I'd probably use a separate class e.g.:

.alternativeFrame {
    position: absolute;
    left: 50px;
}

And then use addClass and removeClass:-

$('#frame').addClass('alternativeFrame');
$('#frame').removeClass('alternativeFrame');

Or just:-

$('#frame').toggleClass('alternativeFrame');

Also remember that you can chain your selectors together for ease and speed, so for your first example you can end up doing:-

$('#frame').css("position","absolute").css("left",50);
Gavin Gilmour
You can also pass a dictionary to the `css` function: $('#frame').css({"position": "absolute", "left": 50});
Vlad Andersen