There are two divs with a button positioned above them. Initially, only one div, the catalogusOrderBox, is visible. When the button named manualButton is clicked, it should display the manualOrderBox div while hiding the catalogusOrderBox div. The text on the button should also change from "manual button" to "catalogus button" for easy navigation. Clicking the button again should reverse the visibility of the divs.
The current code implementation is not working as intended:
<script type="text/javascript">
$(document).ready(function(){
$('.manualOrderBox').hide().before('<a href="#" id="toggle-manualOrderBox" class="manualButton">manual order box</a>');
$('a#toggle-manualOrderBox').click(function() {
$('.manualOrderBox').slideToggle(1000);
if($('.manualOrderBox').is(":visible")){
$('.catalogusOrderBox').hide();
$('.manualOrderBox').visible = false;
}else{
$('.manualOrderBox').visible = true;
$('a#toggle-manualOrderBox').text('catalogus orderBox');
$('.catalogusOrderBox').show();
}
return false;
});
});
</script>
<div class="manualOrderBox">
To see this issue in action, visit https://jsfiddle.net/Lbot8a8b/.