所以我现在有这个代码。基本上我有一个按钮,你点击它,按钮所在的 div 关闭,另一个 div 切换。问题是我想制作一堆按钮,这些按钮将根据您单击的内容将不同的内容加载到第二个 div 中。有没有人对实现这一目标的最佳方法有任何想法?http://jsfiddle.net/PDzFj/
jQuery
$(function() {
$('.clickme').click(function() {
var tot = $('.maindiv');
var exp = $('.contentdiv');
var frt = (tot.is(":visible"))?tot:exp;
var lst = (tot.is(":visible"))?exp:tot;
frt.slideToggle('slow','easeInOutExpo', function() {
lst.slideToggle('slow','easeInOutExpo', function() {/*complete*/});
});
});
});
HTML
<div class="wrapper">
<div class="maindiv">
<div class="button clickme">Page One</div>
<div class="button clickme">Page Two</div>
<div class="button clickme">Page Three</div>
<div class="button clickme">Page Four</div>
<div class="clearit"></div>
</div>
<div class="contentdiv">
<div class="button clickme">Back</div>
Different content loads here (eg. page one, page two, page three...)
</div>
</div>
CSS
.wrapper{
width:800px;
}
.maindiv{
width:760px;
padding:20px;
background:lightblue;
}
.contentdiv{
width:760px;
padding:20px;
background:blue;
display:none;
}
.button{
background:#eee;
height:100px;
width:100px;
text-align:center;
line-height:100px;
margin:2px;
float:left;
}
.clearit{
clear:both;
}