While processing an image I’m trying to reduce the size of the current thumb using animate and apply an overlay. The overlay is working but I can’t seem to get animate working and I think it has something to do with the way I’m finding the image.
Here is the HTML:
<img id='loading' />
....
<tr>
<td>
<img id="5" src="<?php echo($url['url'])?>" style="height:120px;"/>
</td>
<td>
<a href="#" id="img_5" class="test">Test Overlay</a></li>
</td>
</tr>
CSS:
#loading {
position: absolute;
display: none;
background:transparent url(../../images/overlay.png) repeat top left;
}
My current click event looks like this:
$('.test').click(function(e) {
e.preventDefault();
var loading_img = $('#loading');
var id = $(this).attr('id').substr(4);
var img = $('#' + id);
var pos = img.offset();
var $image = $('#' + id).find('img:first');
$image.stop(true)
.animate({
'width' :img.width() - 10 + 'px',
'height':img.height() - 10 + 'px',
},250);
loading_img.show().css({
width: img.width(),
height: img.height(),
left:pos.left,
top:pos.top
});
});
Any idea what I’m missing with my animate call?
Prior to HTML5 id’s could not start with a numeric character. Without the HTML5 doctype, using such id’s may not work in all browsers.