...

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



mda2711
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

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

Exodious
10-19-2003, 01:24 PM
<script>
function toggleDiv(div)
{
if(div.style.display == "none")
div.style.display = "block";
else
div.style.display = "none";
}
</script>

<body>

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


</body>


Simple example for you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum