在這裏你去:
分析
1.初始狀態
<div class="img_wrap">
<div class="img_panel" title="pixi">pixi</div>
<div class="img_panel" title="mus">mus</div>
<div class="img_panel" title="flash">flash</div>
<div class="img_panel" title="dir">dir</div>
<div class="img_panel" title="rpi">rpi</div>
<div class="img_panel" title="ac">ac</div>
<div class="img_panel" title="css">css</div>
<div class="img_panel" title="nagraj">nagraj</div>
</div>
2.點擊「AC」
<div class="img_wrap">
<div class="img_panel" title="pixi">
<img src="img/clients/ac/ac_top.jpg" width="1040" height="217" alt="aucourant"><img src="img/clients/ac/ac1.jpg" width="1040" height="502" alt="aucourant">
</div>
<div class="img_panel" title="mus">
<img src="img/clients/ac/ac_top.jpg" width="1040" height="217" alt="aucourant"><img src="img/clients/ac/ac1.jpg" width="1040" height="502" alt="aucourant">
</div>
<div class="img_panel" title="flash">
<img src="img/clients/ac/ac_top.jpg" width="1040" height="217" alt="aucourant"><img src="img/clients/ac/ac1.jpg" width="1040" height="502" alt="aucourant">
</div>
<div class="img_panel" title="dir">
<img src="img/clients/ac/ac_top.jpg" width="1040" height="217" alt="aucourant"><img src="img/clients/ac/ac1.jpg" width="1040" height="502" alt="aucourant">
</div>
<div class="img_panel" title="rpi">
<img src="img/clients/ac/ac_top.jpg" width="1040" height="217" alt="aucourant"><img src="img/clients/ac/ac1.jpg" width="1040" height="502" alt="aucourant">
</div>
<div class="img_panel" title="ac" style="display: block;">
<img src="img/clients/ac/ac_top.jpg" width="1040" height="217" alt="aucourant"><img src="img/clients/ac/ac1.jpg" width="1040" height="502" alt="aucourant">
</div>
<div class="img_panel" title="css">
<img src="img/clients/ac/ac_top.jpg" width="1040" height="217" alt="aucourant"><img src="img/clients/ac/ac1.jpg" width="1040" height="502" alt="aucourant">
</div>
<div class="img_panel" title="nagraj">
<img src="img/clients/ac/ac_top.jpg" width="1040" height="217" alt="aucourant"><img src="img/clients/ac/ac1.jpg" width="1040" height="502" alt="aucourant">
</div>
</div>
說明
每個img_panel
具有用於 「AC」 報頭的圖像。他們沒有CSS display:none;
,這意味着這些div是可見的。執行時,
$('.img_panel:visible').fadeOut(1000, function() {
$(this).appendTo(ticker);
ticker.children().first().show(function(){
var artit = $(this).attr('title');
$(this).load(artit+'.txt');
});
當前項目被隱藏並顯示下一個項目。在過渡期間,當前和下一個項目都會部分隱藏,並且背景div中的圖像會顯示。
有問題的代碼
$('.work li').click(function(){
var clientitle = $(this).attr('title');
$('.work').fadeOut(500), $('.big_images').delay(500).fadeIn();
$('.img_panel[title="'+clientitle+'"]').fadeIn();
var cltxt = clientitle+'.txt'
$('.img_panel').load(cltxt);
});
解決方案
// Only load data to active div
$('.img_panel[title="' + clientitle + '"]').load(cltxt);
而且,這是更好地做到這一點:
// Hide all divs
$('.img_panel').hide();
// Load and unhide active div
$('.img_panel[title="' + clientitle + '"]').load(cltxt).show();
問題2
當你點擊「AC」,然後單擊Next
,代碼變成這樣:
<div class="img_wrap" style="display: block;">
<div class="img_panel" title="pixi" style="display: block;">...</div>
<div class="img_panel" title="mus">...</div>
<div class="img_panel" title="flash">...</div>
<div class="img_panel" title="dir">...</div>
<div class="img_panel" title="rpi">...</div>
<div class="img_panel" title="css">...</div>
<div class="img_panel" title="nagraj">...</div>
<div class="img_panel" title="ac" style="display: none;">...</div>
</div>
看到,ac
元素進入到最後的,作出該命令錯誤的下一迭代。
解決方案
沒有必要重新排列div
元素。只需使用一系列標題和索引即可處理next
和prev
。
不錯的設計,我喜歡它 – kidwon
@kidwon謝謝:) – sandeep
哪個瀏覽器出現這個問題? –