Jump to content

Hide/show function


dennylin93

Recommended Posts

To show or hide some thing in your page use the property .style.display in the element you want to show/hide... for example:

<script type="text/javascript">function showHide(id){var element = document.getElementById(id); try{ if(element.style.display == "none") {element.style.display = "";}} catch (e) { //do something if the id provided doesn-t obtain an element from your document}}

PD: you can replace line <element.style.display = "";> with element.style.display = "block"; too

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...