I have a menu with 7 elements, where clicking on an element causes its content to appear by fading in. If another element is clicked, the current content fades out and the new content fades in. I've successfully implemented this concept for 3 of the 7 elements in my menu, but am encountering 2 issues: 1) Element A isn't fading in properly. 2) There's a timing issue with fading in and out, resulting in potential content collisions. Any suggestions?
HTML:
<div id="menu" class="menu">
<ul class="headlines">
<li id="item1" onclick="checklist(this)"><button>A</button></li>
<li id="item2"><button>B</button></li>
<li id="item3"><button>C</button></li>
<li id="item4"><button>D</button></li>
<li id="item5"><button>E</button></li>
<li id="item6"><button>F</button></li>
<li id="item7"><button>G</button></li>
</ul>
</div>
<div id="first">
<img id="image1" src="http://placehold.it/350x150"/>
<img id="image2" src="http://placehold.it/350x150"/>
<img id="image3" src="http://placehold.it/350x150"/>
<img id="image4" src="http://placehold.it/350x150"/>
<img id="image5" src="http://placehold.it/350x150"/>
<img id="image6" src="http://placehold.it/350x150"/>
<img id="image7" src="http://placehold.it/350x150"/>
<img id="image8" src="http://placehold.it/350x150"/>
<img id="image9" src="http://placehold.it/350x150"/>
<img id="image10" src="http://placehold.it/350x150"/>
</div>
<div id="second">
<img id="image1" src="http://placehold.it/350x150"/>
<img id="image2" src="http://placehold.it/350x150"/>
<img id="image3" src="http://placehold.it/350x150"/>
<img id="image4" src="http://placehold.it/350x150"/>
<img id="image5" src="http://placehold.it/350x150"/>
<img id="image6" src="http://placehold.it/350x150"/>
<img id="image7" src="http://placehold.it/350x150"/>
<img id="image8" src="http://placehold.it/350x150"/>
<img id="image9" src="http://placehold.it/350x150"/>
<img id="image10"src="http://placehold.it/350x150"/>
</div>
<div id="third">
<img id="image1" src="http://placehold.it/350x150"/>
<img id="image2" src="http://placehold.it/350x150"/>
<img id="image3" src="http://placehold.it/350x150"/>
<img id="image4" src="http://placehold.it/350x150"/>
<img id="image5" src="http://placehold.it/350x150"/>
<img id="image6" src="http://placehold.it/350x150"/>
<img id="image7" src="http://placehold.it/350x150"/>
<img id="image8" src="http://placehold.it/350x150"/>
<img id="image9" src="http://placehold.it/350x150"/>
<img id="image10"src="http://placehold.it/350x150"/>
</div>
CSS:
#first
{
display: none;
width: 50%;
height: 220px;
margin:auto;
padding-left: 150px;
margin-top: -215px;
}
#first img
{
height: 100px;
width: 100px;
float:left;
margin-right: 5%;
cursor: pointer;
}
#second
{
display: none;
width: 50%;
height: 220px;
margin:auto;
padding-left: 150px;
margin-top: -215px;
}
#second img
{
height: 100px;
width: 100px;
float:left;
margin-right: 5%;
cursor: pointer;
}
#third
{
display: none;
width: 50%;
height: 220px;
margin:auto;
padding-left: 150px;
margin-top: -215px;
}
#third img
{
height: 100px;
width: 100px;
float:left;
margin-right: 5%;
cursor: pointer;
}
li{
list-style-type: none;
font-size: 1.5em;
height: 40px;
width: 180px;
text-align:right;
border-style: none;
}
.menu{
width:150px;
height: 350px;
}
.menu li{
position: relative;
top:150px;
bottom: 0;
left: 695px;
right:0;
margin: auto;
border-style:none;
}
JQUERY:
$(document).on('click','#item1', function()
{
$("#second, #third").fadeOut(2000, function(){
$("#first").fadeIn(6000);
});
});
$(document).on('click','#item2', function()
{
$("#first, #third").fadeOut(2000, function(){
$("#second").fadeIn(6000);
});
});
$(document).on('click','#item3', function()
{
$("#first, #second").fadeOut(2000, function(){
$("#third").fadeIn(6000);
});
});
JSFIDDLE: http://jsfiddle.net/ktyxr77y/