Jump to content


Photo

Element ID problem


  • Please log in to reply
1 reply to this topic

#1 slipperyfish

slipperyfish
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 21 March 2006 - 12:24 PM

Hey, im new to js.. Iv made this fairly simple script, however im having problems with the "hidenav()" funtion. I thought the easiest way to hide it, would be make the "visible" - "0" .. obviouslly hiding it. (If there is a better way please let me know) .. im just having problems trying to hide it?

Here's my script:

<html>
<head>
<title>Nebwie Style. DHTML Menu1</title>

<script TYPE="text/javascript"><!--

function displayNav()
{

    boxdiv = document.createElement('div');

    boxdiv.style.display = 'block';
    boxdiv.id = 'myDiv';
    boxdiv.style.position = 'absolute';
    boxdiv.style.width = '100px';
    boxdiv.style.top = '100px';
    boxdiv.style.left = '100px';
    boxdiv.style.height = '200px';
    boxdiv.style.backgroundColor = '#3E3D40';
    boxdiv.innerHTML = 'Test!';

    document.body.appendChild(boxdiv);

    return false;
}

function hideNav()
{
    getElementById('myDiv').style.visible="no";

}
    

//--></script>

</head>
<body>

<p onMouseOver="return displayNav();" onMouseOut="return hideNav();">Show Nav</p>

</body>
</html>

As i said I am new to js.. any help much appreciated!

#2 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 23 March 2006 - 11:17 AM

Might work by changing the following:

function hideNav()
{
    document.getElementById('myDiv').style.display="none";

}

OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users