...

View Full Version : why does this not work?



glenelkins
11-17-2006, 10:06 AM
Hi

I have the following at the top of the page



<script language="JavaScript">
document.getElementById('form').style.display = 'none';
</script>


then a <div id='form'>contents</div> why does it not hide the div??

coothead
11-17-2006, 11:49 AM
Hi there glenelkins,

the div does not exist when the javascript is parsed.
So try it like this...


<script type="text/javascript">
window.onload=function() {
document.getElementById('form').style.display='none';
}
</script>

Also note that lanquage="javascript" is deprecated. Use type="text/javascript" instead.

coothead



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum