I am facing an issue with toggling the visibility of two divs using a button click event. One div is initially hidden with a display property set to none, while the other div is visible.
My goal is to have this behavior toggle on each click event - the first div becoming visible while the second one becomes hidden, and vice versa.
Unfortunately, I do not have any experience with Jquery, which makes finding a solution challenging. Can anyone help me achieve this functionality?
I attempted to resolve this problem by implementing the following code snippet:
<script>
$(document).ready(function(){
$("#filter").click(function(){
$("#sidebar").toggle(function(){
$("#sidebar").hide();
$(".right-box").show();
}, function(){
$("#sidebar").show();
$(".right-box").hide();
});
});
});
</script>
However, the implementation does not work as expected. The divs appear and disappear quickly without the intended smooth transition.