How to Show / Hide a DIV

Rate: 1 Star Rate: 2 Stars Rate: 3 Stars Rate: 4 Stars Rate: 5 Stars

Love it / Hate it

Comments + Likes

How to Show / Hide a DIV

Programming / Javascript

How to Show / Hide a DIV

This Tutorials shows you to show / hide a div using Javascript. This is quite a simple tutorial.
How to Show / Hide a DIV was posted by listylister and has had 427 view(s) with an overall rating of 4
Chris's Profile Picture

Posted by listylister

Their Website http://www.phptutor...

This Tutorial has had 427 Views

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 30/05/2010 @ 16:00
aProject.info Twitter RSS

  Copyright PHPTutorials.co © 2009 - 2010