Cart

JavascriptSnippets

OnClick Button Display / Hide Div

By March 31, 2020April 11th, 2020No Comments

This snippet is used in Salient when a nectar button style needs an OnClick function for displaying / hiding div. Just remember to include the ID for the div you want to control.

<style&gt;
#divID{display:none;}
</style&gt;
<a onclick="display_div()" class="nectar-button large regular accent-color  regular-button" id="read-disclaimer" style="visibility: visible;" href="#" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"&gt;<span&gt;Submit a Listing (I have read the disclaimer above)</span&gt;</a&gt;
<script&gt;
function display_div() {
  var x = document.getElementById("divID");
  if (x.style.display === "block") {
    x.style.display = "none";
  } else {
    x.style.display = "block";
  }
}
</script&gt;

Contact us to learn about adopting the web for your business

Jarod Thornton

Author Jarod Thornton

More posts by Jarod Thornton