单击文本菜单时,照片淡入和标题也会淡入放置在单独的位置。我无法整合标题。如果有更好的方法可以做到这一点,我将不胜感激。
演示:http: //jsfiddle.net/Tacbs/4/
$(document).ready(function() {
$("div#photos, div#photo-titles").hide();
var divs = $("#Photo1, Photo1-Title, #Photo2, Photo2-Title, #Photo3, Photo3-Title,");
$("li a").click(function () {
$(divs).hide();
$("#" + $(this).attr("class")).fadeIn();
});
});
#photo-titles {
margin-top: 0;
}
#photos {
margin-top: 100px;
}
#photo-titles {
margin-top: 200px;
}
<div id="photo-links">
<ul>
<li><a href="#" class="Photo1 Photo1-Title">Photo 1 Button</a></li>
<li><a href="#" class="Photo2 Photo2-Title">Photo 2 Button</a></li>
<li><a href="#" class="Photo3 Photo3-Title">Photo 2 Button</a></li>
</ul>
</div>
<div id="photos">
<div id="Photo1"><img src="Photo1.jpg"/></div>
<div id="Photo2"><img src="Photo1.jpg"/></div>
<div id="Photo3"><img src="Photo1.jpg"/></div>
</div>
<div id="photo-titles"> // text
<div id="Photo1-Title">Photo Title 1</div>
<div id="Photo2-Title">Photo Title 2</div>
<div id="Photo3-Title">Photo Title 3</div>
</div>