Search
 
SCRIPT & CODE EXAMPLE
 

HTML

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
Html :: how to inlcudes js in html 
Html :: boostrap thymeleaf modal 
Html :: How do I move my header to the right side in HTML? 
Html :: insert html in word 
Html :: how to set up html basic workspace 
Html :: hide input field title show when it is filled 
Html :: intellij html 
Html :: nombre y etiquetas de html5 
Html :: freecodecamp step 3 quiz 
Html :: How to display data from database in HTML 
Html :: search/find content ftp html 
Html :: how to make password in html correct or incorrect 
Html :: aria-haspopup 
Html :: como remover primeiro elemento de um array javascript 
Html :: html api 
Html :: javascript timespan 
Html :: pass parameter and jump to particular section 
Html :: mp4 start time html 
Html :: @click event disabled source 
Html :: color ful scroll bar 
Html :: display letter in html element letter by letter 
Html :: html exporting table is displaying numbers as dates 
Html :: Make Input Group Responsive Input Append (Search And Dropdown With Buttons) 
Html :: embed elm into html 
Html :: how to send the data through url in html without using the form 
Html :: angular pass data without -let 
Html :: buttosn html 
Html :: HRECURS - Hello Recursion 
Html :: how to hide youtube watermark from embedded video :2021 
Html :: camerx mlkit barcode scanner 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =