Javascript toggle show/hide div or anything

You would manipulate the elements by toggling between styling rather than changing the elements based on the innerHTML. In this case, you would toggle between display:none and display:block.

Example:

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

By Keenlio, October 14, 2014

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


× 1 = two

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>