2010-07-23 56 views
0

我試圖解決一個jQuery的問題我的代碼是負載不會在jQuery的工作,幫助請

<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> 

這個腳本的工作,除了IE和Opera所有的瀏覽器,我怎樣才能解決這個問題? 其實我想設置圖像中的容器(DIV)垂直方向的中間

謝謝你們

回答

1

嘗試

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

其實$( '#IMG')。負載(函數()有問題 – milan 2010-07-23 08:11:16

+0

這是什麼問題? – Reigel 2010-07-23 08:16:21