I am attempting to incorporate a script (written by "dystroy" I believe) that centers an image vertically within a div with the overflow hidden. It works quite well but many of my images are dynamically loaded upon mouseover.
I need to find a way to call the script upon image load. It's been two days now and as JS/JQuery aren't my native language, I find my self here.
Can anyone suggest how I might get the following to fire on image load? Many thanks!
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$('.container').each(function () {
var $img = $(this).find('img');
$(this).scrollTop(($img.height() - $(this).height()) / 2);
$(this).scrollLeft(($img.width() - $(this).width()) / 2);
});
});
//]]></script>