Your Cart

Get Amazing Offers on Scripts

Get UX Support

How to switch between the visibility of two div elements using a single button with pure JavaScript?

				
					<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#menuCollapsed{
  width: 100%;
  padding: 50px 0;
  text-align: center;
  background-color: lightblue;
  margin-top: 20px;
}
#menuopen {
display:none;
}
</style>
</head>
<body>

<p>Click the "Try it" button to toggle between hiding and showing the DIV element:</p>

<button onclick="menuAction()">Try it</button>

<div id="menucollapsed">
This is my DIV element.
</div>

<div id="menuopen" >
This is my DIV elemsssent.
</div>

<p><b>Note:</b> The element will not take up any space when the display property 
is set to "none".</p>



</body>
</html>


				
			
Leave a Reply
Fast Download

Instant access to your digital products right after purchase.

Custom Softwares

Completely build by Tutorialslides

Latest Sofware Updates

Offered in the country of usage

100% Secure Checkout

PayPal / MasterCard / Visa