views:

23

answers:

1

Hi all

I am trying to fix one jquery issue my code is

<script language="javascript">
    $(document).ready(function() {
         //if the document is ready
        $('#img').load(function() { 
            //if the image is loaded
            pic_real_height = this.height;
            //finding the height of the image
            $('#img').css('margin-top', 150 - pic_real_height / 2 + 'px');  //setting the margin-top to align the image verticall middle in the container<br>
        });  
    });
</script>

This scripts works in all browsers except IE and opera, How can I fix this issue ? Actually I want to set the image vertically middle in a container (div)

Thank you guys

+1  A: 

try

pic_real_height = $(this).height();
Reigel
Actually $('#img').load(function() has the problem
milan
what problem is that?
Reigel