我正在从头开始重建网站,我想知道如何才能做到这一点:
当我单击两个按钮之一时,将出现另一个视图。我该如何实现?
我尝试了这个:http : //jsfiddle.net/7bqjm1dy/
$("#b1").click(function() {
$("#first").slideDown();
$("#sec").slideUp();
});
$("#b2").click(function() {
$("#sec").slideDown();
$("#first").slideUp();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div style="vertical-align:top; display:inline;">
<button id="b1">Click 1</button><br />
<button id="b2" >Click 2</button>
</div>
<div>
<div id="first" style="display:none; background-color:red; width:100px; height:200px;"></div>
<div id="sec" style="display:none; background-color:blue; width:100px; height:200px;"></div>
</div>
但这并不符合我的要求。我想要一个slideFromLeft,我想对齐按钮和地图。
我更新了您的小提琴:
的HTML
<div style="vertical-align:top; display:inline;" class="buttons">
<button id="b1">Click 1</button><br />
<button id="b2" >Click 2</button>
</div>
<div class="boxes">
<div id="first" style="background-color:red; width:100px; height:200px;"></div>
<div id="sec" style="display: none; background-color:blue; width:0px; height:200px;"></div>
</div>
Java脚本
$("#b1").click(function() {
$("#sec").animate({'width': 0}, 'fast', function(){
$(this).hide();
$("#first").show().animate({'width': '100px'});
});
});
$("#b2").click(function() {
$("#first").animate({'width': 0}, 'fast', function(){
$(this).hide();
$("#sec").show().animate({'width': '100px'});
});
});
的CSS
.boxes, .buttons{
float: left;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句