aProject - Viewing Tutorial How to Show / Hide a DIV

PHP Programming / How to Show / Hide a DIV

go back
please cast your vote:

Rate: 1 Star Rate: 2 Stars Rate: 3 Stars Rate: 4 Stars Rate: 5 Stars
Posted by: Chris
Their Website: http://www.chrispriestland.co.uk

This Tutorial has had 177 Views


Shows you to show / hide a div using Javascript

Showing / Hiding a DIV is very easy. The following function should be inserted just before the end body tag on your page.





<script language="javascript" type="text/javascript">



function showhide(ID){



var tmp = document.getElementById(ID);



if (tmp.style.display=='none'){



tmp.style.display = '';



}else{



tmp.style.display = 'none';



}



}



</script>





The following function can then be called to toggle the divs display status:





<div id="helloworld">Hello World</div>

<div onclick="showhide('helloworld');">Show / Hide</div>





Hope this helps you out

created on 20/12/2009 @ 15:57, last updated on 09/03/2010 @ 19:51

Comments

There are no comments for this tutorial yet.

Please login to post a comment.


  Copyright aProject © 2009 - 2010