2010-11-28 87 views
4

以下代碼示例正在使用中,圖像在任何IE版本中都不會顯示。圖像不在IE中呈現

HTML代碼:

<div class="container" style="text-align:center;"> 
<ul class="thumb"> 
    <li style="height:220px; padding: 0 40px 0 0; overflow:visible; 
     position: relative;"> 
    <img width="246px" height="208px" src="images/about4.jpg" 
     alt="Biomimetic and Biological Materials"/> 
    </li> 
</ul> 
</div> 

的jQuery:

<script type="text/javascript"> 
$(document).ready(function(){ 

//Larger thumbnail preview 

$("ul.thumb li").hover(function() { 
    $(this).css({'z-index' : '10'}); 
    $(this).find('img').addClass("hover").stop() 
     .animate({ 
      marginTop: '-110px', 
      marginLeft: '-110px', 
      top: '50%', 
      left: '50%', 
      width: '600px', 
      height: '400px', 
      padding: '20px' 
     }, 200); 

    } , function() { 
    $(this).css({'z-index' : '0'}); 
    $(this).find('img').removeClass("hover").stop() 
     .animate({ 
      marginTop: '0', 
      marginLeft: '0', 
      top: '0', 
      left: '0', 
      width: '246px', 
      height: '208px', 
      padding: '5px' 
     }, 400); 
}); 

//Swap Image on Click 
    $("ul.thumb li a").click(function() { 

     var mainImage = $(this).attr("href"); //Find Image Name 
     $("#main_view img").attr({ src: mainImage }); 
     return false;  
    }); 
}); 
</script> 

難道我做錯了什麼?謝謝:)

回答

1

嘗試將'交換圖像點擊'點擊處理程序內部$(document).ready(function() {,以確保它是綁定一旦DOM準備好JavaScript處理。

+0

我錯過了關閉});但它已經在$(document).ready(function(){... :( – 2010-11-28 09:06:57

0

看看你的佈局和引用代碼 您正在搜索:

$("ul.thumb li a") 

但「u​​l.thumb禮」你只有「IMG」標籤,而不是「一」下。

可能是問題所在。