Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing height of a div element using javascript or jquery but it must change slowly

Hi I have set a background in a div element and i want to increase the height of that div tag when I click on an anchor tag. But i want the height to be increased slowly.

like image 608
JayP Avatar asked Dec 20 '22 15:12

JayP


2 Answers

You can change the duration of the animation:

$('#element').animate({
    height: '200px'
}, {
    duration: 2000  // 2 seconds
});

Demo: http://jsfiddle.net/t5VYa/

like image 146
Blender Avatar answered May 12 '23 13:05

Blender


Use jquery's animate function.

$('#selector').animate({
    height: '500px'
  }, 5000, function() {
    // Animation complete.
});

where 5000 is the duration in milliseconds

like image 22
VVV Avatar answered May 12 '23 12:05

VVV