Youss
Youss

Reputation: 4212

How to slide up a div 15px to the top

 $("SomeInputField").keydown(function () {

     $("SomeDiv").css("top", "30px");
 });

First this is making a div go 30px from the top

 $("SomeInputField").bind("keyup", function () {

     $(this).val() == "" && $("SomeDiv").css("top", "15px");
 });

Second, this is making the div go up 15px.

My question: How can I make the div in the second code go up "smoothly", so not "instant" but with some sort of slide up(15px) event.

Upvotes: 0

Views: 161

Answers (2)

Matt
Matt

Reputation: 1265

you can use the .animate() jquery function

http://api.jquery.com/animate/

$("SomeDiv").animate({top: 15}, 1000);

you can adjust the 1000 to adjust the speed

Upvotes: 1

mqchen
mqchen

Reputation: 4193

If I understand you correctly, you could try animate().

For example:

$("SomeDiv").animate({ top: 15 });

Upvotes: 1

Related Questions