Search the Blog

Monday, July 29, 2019

Javascript code Hide and Show of a Button -Programming Logic and Code with Syntax Dizsweb


<html>

<head>
<style>
#myDIV {
  width: 150%;
  padding: 75px 0;
  text-align: center;
  background-color: lightblue;
  margin-top: 20px;
}
</style>
</head>

<body>

<button onclick="myFunction()">WWW.DIZSWEB.COM

</button>


<div id="myID">
This is my DIV element.
</div>
// JAVAScipt which will work to hide and show

<script>

function myFunction() {
  var x = document.getElementById("myID");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}

</script>


</body>

</html>

No comments:

Post a Comment

Translate