Hello, I’m softpedian and I’m new here.
I started learning javascript few weeks ago and after several readings I started to make a menu. Well, I don’t have experience on events, that’s for sure. My problem is that I don’t want to start with the wrong foot.
All i want it’s that from an image, on mouse hover to create a div( or several divs ) and to remove the divs only if the mouse it’s not on divs or image!
What I did is this:
[code]
<html>
<head>
<title>Javascript DOM</title>
<script type=”text/css”>
</script>
<script type=”text/javascript” language=”javascript”>
function CreateDiv()
{
var t = document.createElement(“div”);
t.id = “div1”;
t.setAttribute(‘style’,’position:absolute; top:80; left:90′);
t.innerHTML = “<a href=”www.google.ro”><img src=’3.png’ id = ‘h’ border = ‘0’ onmouseover=”document.getElementById(‘h’).src = ‘4.png'” onmouseout=”RemoveDiv()”>”;
document.body.appendChild(t);
}
function RemoveDiv()
{
var p2 = document.getElementById(‘div1’);
p2.parentNode.removeChild(p2);
}
</script>
</head>
<body>
<div style=”position:absolute; top:20; left: 100;”><a href=”www.google.ro”><img border =”0″ id=”hey” src=”1.png” onmouseover= “CreateDiv()” onmouseout=”RemoveDiv()”></a></div>
</body>
</html>
Attention! I don’t want code, I just want an idea or some code where to start! I want to understand, that’s for sure. Thanks!