You should make 2 functions:
- ShowObject(objectId)
- CloseObject(objectId)
And two global variables:
var maxHeight = 300;
var curHeight;
ShowObject(objectId)
sets a Interval of for example every 20 miliseconds in which he calls itself again. Each time the function gets called it increases the height with 3px. If the maximum height has been reached (for example 300px) it stops the interval. CloseObject(objectId)
does exactly the same as ShowObject(objectId)
, but decreases the height at each function call until it reaches for example 10px.
To retrieve the object's height you should use the codeline curHeight = document.getElementById(objectId).height
Good luck!
~G