hide element by name javascript

JavaScript
function myFunction() {
  var x = document.getElementById("myDIV");

    if (x.style.display 
=== "none") {
    x.style.display = "block";
  } else {
    x.style.display = 
  "none";
  }
} <button onclick="myFunction()">Click Me</button>

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

Also in JavaScript: