Template:Navbox Example.: Difference between revisions

From Funkinchan
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
<div class="navbox">
$(document).ready(function() {
    <div class="navbox-header">
     $(".navbox-header").click(function() {
        <!-- Add a header/title for your navbox -->
         $(this).next(".navbox-content").slideToggle();
        Navigation
    });
        <span class="collapse-button">[<a href="javascript:void(0);" class="collapse-link" onclick="toggleNavbox(this)">hide</a>]</span>
});
     </div>
    <div class="navbox-content">
        <!-- Add your content here -->
        * [[Page 1]]
        * [[Page 2]]
        * [[Page 3]]
    </div>
</div>
 
<script>
    function toggleNavbox(element) {
         var content = element.parentElement.parentElement.nextElementSibling;
        if (content.style.display === "none" || content.style.display === "") {
            content.style.display = "block";
            element.textContent = "hide";
        } else {
            content.style.display = "none";
            element.textContent = "show";
        }
    }
</script>

Revision as of 02:27, 3 October 2023

$(document).ready(function() {

   $(".navbox-header").click(function() {
       $(this).next(".navbox-content").slideToggle();
   });

});