View Full Version : How can I control CSS attributes with javascript?

10-19-2003, 11:44 AM
I saw an idea on another website and i wan't to incorporate it into mine.
How can I use javascript to control the css "display" attribute and change it from "none" to "block" on a div

10-19-2003, 12:37 PM
do you mean hidden?

10-19-2003, 01:24 PM
function toggleDiv(div)
if(div.style.display == "none")
div.style.display = "block";
div.style.display = "none";


<table cellpadding="3" cellspacing="0" width="300" bgcolor="#cccccc" style="border: thin solid black">
<td style="cursor:hand;" onclick="toggleDiv(document.all.testdiv);">
<font face="arial">
To toggle div display, click on this row
<td bgcolor="#dbdbdb">
<div id="testdiv" name="testdiv" style="display:block;">
<font face="arial">
The divs content


Simple example for you

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum