我一直在关注 JS 灯箱的教程,但我并不完全理解如何在多个 div 上使用它。
我想要的是同一个灯箱,但我希望里面的内容根据我按下的按钮/链接而有所不同。
任何帮助,将不胜感激。我将在下面发布相关的片段。
HTML:
<ul id="portfolioitems">
<li><a href="#1" rel="nofollow" id="1"><img src="images/digitaltattoo.jpg"><div>Digital Tattoo</div></a></li>
<li><a href="#2" rel="nofollow" id="2"><img src="images/flashgame.jpg"><div>Flash Game - Deserted</div></a></li>
<li><a href="#3" rel="nofollow" id="3"><img src="images/photos.jpg"><div>Photography</div></a></li>
<li><a href="#4" rel="nofollow" id="4"><img src="images/bumper.jpg"><div>Video Bumper</div></a></li>
<li><a href="#5" rel="nofollow" id="5"><img src="images/fbfanaticism.jpg"><div>Facebook Fanaticism</div></a></li>
<li><a href="#6" rel="nofollow" id="6"><img src="images/oldwebsite.jpg"><div>Business Card Website</div></a></li>
</ul>
<div id="1">
<div class="contentwindowwrapper">
<div class="contentwindow">
<div class="contentwindowclose">x</div>
4365786
</div>
</div>
</div>
<div id="2">
<div class="contentwindowwrapper">
<div class="contentwindow">
<div class="contentwindowclose">x</div>
reerrhr
</div>
</div>
</div>
JS:
$(document).ready(function(){
var divnumber = $(this).attr("href");
$('#1').click(function(){
$('.contentwindowwrapper, .contentwindow').animate({'opacity':'1.00'}, 100, 'linear');
$('.contentwindow').animate({'opacity':'1.00'}, 100, 'linear');
$('#1, .contentwindowwrapper, .contentwindow').css('display', 'block');
$('.contentwindowwrapper, .contentwindow').css('z-index', '1');
});
$('#2').click(function(){
$('.contentwindowwrapper, .contentwindow').animate({'opacity':'1.00'}, 100, 'linear');
$('.contentwindow').animate({'opacity':'1.00'}, 100, 'linear');
$('#2, .contentwindowwrapper, .contentwindow').css('display', 'block');
$('.contentwindowwrapper, .contentwindow').css('z-index', '1');
});
$('.contentwindowclose').click(function(){
close_contentwindow();
});
$('.contentwindowwrapper').click(function(){
close_contentwindow();
});
});
function close_contentwindow()
{
$('.contentwindowwrapper, .contentwindow').animate({'opacity':'0'}, 100, 'linear', function(){
$('.contentwindowwrapper, .contentwindow').css('display', 'none');
$('.contentwindowwrapper, .contentwindow').css('z-index', '-1');
});
}
谢谢