开发者

load is not working in jquery, help please

开发者 https://www.devze.com 2023-01-08 07:22 出处:网络
I am trying to fix one jquery issue my code is <script language=\"javascript\"> $(document).ready(function() {

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() { 
   开发者_StackOverflow中文版         //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


try

pic_real_height = $(this).height();
0

精彩评论

暂无评论...
验证码 换一张
取 消