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>
<meta name="viewport" content="width=device-width, initial-scale=1">
  width: 100%;
  padding: 50px 0;
  text-align: center;
  background-color: lightblue;
  margin-top: 20px;
#menuopen {

<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 id="menuopen" >
This is my DIV elemsssent.

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


Leave a Reply
Free Worldwide shipping

On all orders above $50

Easy 30 days returns

30 days money back guarantee

International Warranty

Offered in the country of usage

100% Secure Checkout

PayPal / MasterCard / Visa