Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript toggle div

<body>
  <div id="first">This is the FIRST div</div>
  <div id="second">This is the SECOND div</div>
  <div id="third">This is the THIRD div</div>
  <button id="toggle">Hide THIRD div</button>

  <script>
    const targetDiv = document.getElementById("third");
    const btn = document.getElementById("toggle");
    btn.onclick = function () {
      if (targetDiv.style.display !== "none") {
        targetDiv.style.display = "none";
      } else {
        targetDiv.style.display = "block";
      }
    };
  </script>
</body>
Comment

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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: react -native-config 
Javascript :: loop for of 
Javascript :: how to add animation over image in Javascript 
Javascript :: javascript advanced concepts 
Javascript :: make triangle with threejs 
Javascript :: the event object 
Javascript :: serializes to the same string 
Javascript :: react map list render dictionary 
Javascript :: self invoking function in javascript 
Javascript :: how to hack facebook 
Javascript :: jquery set timezone 
Javascript :: como agregar items en un array javascript 
Javascript :: buttons js before submit 
Javascript :: javascript random item of array 
Javascript :: how-to-close-current-tab-in-a-browser-window 
Javascript :: find element vs find elements in selenium 
Javascript :: Create a Simple Delay Using setTimeout 
Javascript :: javascript map callback function 
Javascript :: how to use port variable in axios 
Javascript :: TypeError: Expected a string but received a undefined 
Javascript :: playSound in draw loop javascript 
Javascript :: js arrotondare superiore numero 
Python :: install matplotlib conda 
Python :: save a dict to pickle 
Python :: simple flask hello world 
Python :: python read json file 
Python :: python sleep random 
Python :: find time of run for python code 
Python :: how to round the values in a list 
Python :: make tkinter btn disable 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =