Reputation: 31
<script type="text/javascript">
$(document).ready(function(){
$("#toggle").toggle(
function(){
$("#box1").slideToggle(800,function(){
$("#box2").slideToggle();
});
},
function(){
$("#box2").slideToggle(800,function(){
$("#box1").slideToggle();
});
}
);
});
</script>
<div id="box1">
<a href="#" class="order" id="toggle"> </a>
</div>
<div id="box2" style="display:none;">
<a href="#" class="back" id="toggle"> </a>
</div>
Upvotes: 2
Views: 1025
Reputation:
Firstly you can't have same id for two elements. Secondly jQuery native slide animation works only in top down direction.
<script type="text/javascript">
$(document).ready(function(){
$(".toggle.order").click(
function(){
$("#box1").slideToggle(800,function(){
$("#box2").slideToggle();
});
});
$(".toggle.back").click(
function(){
$("#box2").slideToggle(800,function(){
$("#box1").slideToggle();
});
});
});
</script>
<div id="box1">
<a href="#" class="order toggle"> </a>
</div>
<div id="box2" style="display:none;">
<a href="#" class="back toggle"> </a>
</div>
Upvotes: 0
Reputation: 413976
You can't use the same "id" value for both of those <a>
elements. You gave them different "class" values; maybe you should swap the values for the "class" and "id" attributes.
Upvotes: 4