Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 22, 2022 10:11 am GMT

Hide or show Elements/div in HTML Using JavaScript and Css

Steps :-

  • For This Firstly create a .hidden class where the css display property is set to "none".
<style>  .hidden{    display:none;  }</style>

HTML

  • Then Using JavaScript we will toggle (add / remove) the hidden class from the element. So that results hiding and showing of the div/any other element.
  • Creating a JavaScript function to hide/show elements.
<script>  function hideunhide(a){    document.querySelector(a).classList.toggle('hidden');  }</script>

HTML


Original Link: https://dev.to/sh20raj/hide-or-show-elementsdiv-in-html-using-javascript-and-css-3jb7

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To