I tried the following code:
var origh1 = $('img:first').height();
alert(origh1);
But he warned the value "0".
My img tag has no height value, so it returns 0?
If so, how do I get the image height value?
In addition, I noticed that when I make an animation to increase the size of the image by 20% and reduce it by 20%, it becomes a little larger than the original. How to restore the original image size? And why doesn’t it return to the original if I reduce it by 20%. I know that Math is involved ... but how can I compensate for this in jQuery?
This is my code for this:
$('img:first').fadeIn('normal').delay(500).animate({'height':'+=20%'}, 1500, 'easeOutQuad')
And return to the original:
$('img:first').fadeIn('normal').animate({'height':'-=20%'}, 1000, 'swing');
source
share