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 anima开发者_如何学Pythonte the movement on the change of CSS.
Currently use .toggleClass to achieve this:
$("#div1").click(function() {
$("#div2t").toggleClass('min');
});
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; });
});
If I understood you correctly:
#CSS:
.animate #slip {
top: 10px;
}
#JS
$("element").click(function() {
$(".animate #slip").animate({ top: 0 });
});
$("#div1").click(function(){
$("#div2t").animate({"top":"0px"},"slow");
);
Where slow is the speed , you can put it fast or time in milliseconds without ""
精彩评论