My Jquery code successfully shows and hides divs with a button click, but it seems to only work for the first two clicks. After that, a hashtag appears in the URL and the script stops functioning. I attempted to add `e.preventDefault()` at the beginning of the method, however, this prevented the click event from working at all. Any ideas on what might be causing this issue?
<script>
$(document).ready(function () {
$('.container').hide();
$('.status-icon').text("+");
$('#expandsections').click(function (e) {
var allContentToggleContainers = $('.content-toggle .container');
var allVisibleContentToggleContainers = allContentToggleContainers.filter(function () {
return $(this).css("display") == "block";
});
if (allContentToggleContainers.length && allContentToggleContainers.length === allVisibleContentToggleContainers.length) {
allContentToggleContainers.hide().next().slideUp();
$('.status-icon').text("+");
}
else {
allContentToggles.not('selector:visible').show().next().slideDown();
$('.status-icon').text("+");
}
return false;
});
});
</script>