I’ve an image inside a div, and the following Javascript code:
function animate_down(key1, key2)
{
cimage = document.getElementById('sslot_img' + key1);
var topval = cimage.offsetTop;
if (topval == -416) {
cimage.animate({ top: '0px' }, 5000);
}
else {
topval = topval - 32;
var toptxt = { 'top': topval.toString() };
cimage.animate(toptxt, 5000);
}
}
I’ve test it in Firebug, when the debugger reaches .animate function it’s throwing :
cimage.animate is not a function
what am i missing?
getElementByIdis not a jQuery function, and will not yield a jQuery object.animateis only available on jQuery objects. You need to either wrap yourcimage:or fetch it through jQuery rather than
getElementByIdNote that if you go with the latter option,
cimagewill not have anoffsetTopproperty, but rather, you’d have to useor