javascript hide div
snippet in javascript

javascript hide div

user2043

// javascript
<script>
	document.getElementById("id").style.display = "none";  //hide
	document.getElementById("id").style.display = "block"; //show
	document.getElementById("id").style.display = ""; 	   //show
</script>

// html
<html>
	<div id="id" style="display:none">
    <div id="id" style="display:block">
</html>

// jquery
<script>
	$("#id").hide();      
	$("#id").show();
</script>

hide div in javascript

user4679


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

    if (x.style.display 
=== "none") {
    x.style.display = "block";
  } else {
    x.style.display = 
  "none";
  }
} 

css js show or hide on click

user7657

<script type="text/javascript">
<!--
    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
//-->
</script>

<!-- Inline Usage in HTML -->
<a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a>
<div id="foo">This is foo</div>

js hide element by id

user9121

var link = document.getElementById('nav-ask');
link.style.display = 'none'; //or
link.style.visibility = 'hidden';

toggle element javascript

user4011

document.querySelector("#test").hidden = true;
document.querySelector("#test").hidden = false;