I am encountering a similar issue as described in this thread: same problem (fiddle: original fiddle). However, I am still learning JavaScript and struggling to apply the solution provided because my HTML code is slightly different. Can someone please assist me with this? Once I see how it should be done, I can use it as a learning opportunity.
This is my current code:
<div style="position: absolute; left: 50%;">
<div style="position: relative; left: -50%;">
<div id="101" style="display:none;"><!-- Content here --></div>
<div id="102" style="display:none;"><!-- Content here --></div>
<div id="103" style="display:none;"><!-- Content here --></div>
<div id="104" style="display:none;"><!-- Content here --></div>
<div id="105" style="display:none;"><!-- Content here --></div>
<div id="106" style="display:none;"><!-- Content here --></div>
<div id="107" style="display:none;"><!-- Content here --></div>
<div id="108" style="display:none;"><!-- Content here --></div>
<div id="109" style="display:none;"><!-- Content here --></div>
<div id="110" style="display:none;"><!-- Content here --></div>
<div id="111" style="display:none;"><!-- Content here --></div>
<div id="112" style="display:none;"><!-- Content here --></div>
<div id="113" style="display:none;"><!-- Content here --></div>
</div>
</div>
<script type="text/javascript">
$("#1").on('click', function() {
$("#101").fadeToggle();
$("#102,#103,#104,#105,#106,#107,#108,#109,#110,#111,#112,#113").fadeOut();
});
$("#2").on('click', function() {
$("#102").fadeToggle();
$("#101,#103,#104,#105,#106,#107,#108,#109,#110,#111,#112,#113").fadeOut();
});
// and so on, until #13
</script>
Solution:
$('#indexNav').click(function() {
$('#aboutContent').fadeOut('fast',function(){
$('#indexContent').fadeIn('fast');
});
return false;
});
$('#aboutNav').click(function() {
$('#indexContent').fadeOut('fast',function(){
$('#aboutContent').fadeIn('fast');
});
return false;
});