tags:

views:

43

answers:

3

All I want to do is on .click() is .animate #slip, essentially Im changing the css at the moment from top: 10px to top: 0px

Instead of it being quite clunky i'd like to animate the movement on the change of CSS.

Currently use .toggleClass to achieve this:

    $("#div1").click(function() {
        $("#div2t").toggleClass('min');
    });
A: 

If I understood you correctly:

#CSS:
.animate #slip {
    top: 10px;
}

#JS
$("element").click(function() {
    $(".animate #slip").animate({ top: 0 });
});
Crozin
+3  A: 

You can animate like this:

$(selector).click(function() {
  $("#slip").animate({ top: 0; });
});

Unless you need the .animate container, leave it off...the ID selector is, well, as fast as it gets :)

If you wanted the click to animate it back every other click as well, use .toggle() like this:

$(selector).toggle(function() {
  $("#slip").animate({ top: 0; });
}, function() {
  $("#slip").animate({ top: 10; });
});
Nick Craver
This definitely suits the current updated question +1
c0mrade
@David - `.slideUp()`/`.slideDown()` **hide** and **show** the element, not re-position it, they serve a different purpose. If you wanted that effect, I still wouldn't use those :) ...because there's `.slideToggle()` as well.
Nick Craver
oh yah. duh...i should NOT be posting on SO early in the morning...i need some caffeine. haha.
David Murdoch
A: 
$("#div1").click(function(){
$("#div2t").animate({"top":"0px"},"slow");
);

Where slow is the speed , you can put it fast or time in milliseconds without ""

c0mrade