How to make element invisible in JavaScript

Change the style.visibility to hidden.

element.style.visibility = 'hidden';

Example:

<div id="myElement">This element was visible</div>

<script>
  document.getElementById('myElement').style.visibility = 'hidden';
</script>