Hey all,
Newbie here, so please forgive my approach and specifics. I'd appreciate some help!
I'm working on an image gallery that's got three sections, of which only one will be visible at a time. At the top of the page there are three links that I want to toggle one of the three sections to show while hiding the other two.
The code I've written is poor and works only from Link 1 to Link 2 to Link 3, but not backwards or from link 1 to 3, 3 to 1, etc.
Thanks for your help and advice!
HTML:
<div id="content">
<h2>PHOTOS</h2>
<hr />
<p align="left"><a id="show_promo">PROMO</a> <a id="show_studio">STUDIO</a> <a id="show_live">LIVE</a></p>
<div id="promo">
<p align="center">PROMO</p>
<p align="center">
<img src="#" />
<img src="#" />
<img src="#" />
<img src="#" />
</p>
<p align="center">
<img src="#" />
<img src="#" />
<img src="#" />
<img src="#" />
</p>
</div>
<div id="studio">
<p align="center">STUDIO</p>
<p align="center">
<img src="#" />
<img src="#" />
<img src="#" />
<img src="#" />
</p>
<p align="center">
<img src="#" />
<img src="#" />
<img src="#" />
<img src="#" />
</p>
</div>
<div id="live">
<p align="center">LIVE</p>
<p align="center">
<img src="#" />
<img src="#" />
<img src="#" />
<img src="#" />
</p>
<p align="center">
<img src="#" />
<img src="#" />
<img src="#" />
<img src="#" />
</p>
</div>
</div>
Javascript:
$('#studio').css('display', 'none');
$('#live').css('display', 'none');
$('#show_studio').click(function(){
$('#promo').fadeOut(600, function(){
$('#studio').fadeIn(600);
});
});
$('#show_live').click(function(){
$('#studio').fadeOut(600, function(){
$('#live').fadeIn(600);
});
});
$('#show_promo').click(function(){
$('#live').fadeOut(600, function(){
$('#promo').fadeIn(600);
});
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…