干得好:
分析
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.点击“交流”
<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
.