Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js toggle div

<button onclick="toggleDiv()">Toggle Div</button>

<div id="myDIV" class="hidden">
    This is my DIV content.
</div>

<style>
	.hidden {
      display: none;
    }
</style>

<script>
    function toggleDiv(){
        document.querySelector('#myDIV').classList.toggle('hidden');
    }
</script>
Source by sebhastian.com #
 
PREVIOUS NEXT
Tagged: #js #toggle #div
ADD COMMENT
Topic
Name
8+1 =