Show Button When Div’s ID Available | HTML & JavaScript

Hey! make functionality to show button when div’s id available on HTML’s current page using JavaScript. So use given code on your website.

How to Do

  • First of all paste css code for hide button.
<style>
#simpleButton {
display: none;
}
</style>
  • Then add id’s on button and div tag.
<div id="simpleDiv">Some content</div>
<button id="simpleButton">Click me</button>
  • Then use JavaScript for Show button when Div’s id available.
 <script>
if (document.getElementById("simpleDiv")) {
document.getElementById("simpleButton").style.display = "block";
}
</script>

Then SAVE and take this functionality without using any plugins.