<div style='position:relative'>
<div id ='tag' style=' border: 1px solid red; position : absolute; top: 20px; left: 20px; width: 50px; height: 50px;'></div>
<img src='http://localhost/jlin.jpg' id='wow'>
</div>
This is my html code
window.onload = function(){
var tag = document.getElementById('tag');
tag.onmouseover = function(){
tag.style.visibility = "hidden";
}
tag.onmouseout = function(){
tag.style.visibility = "visible";
}
}
This is my javsacript code. I want the inner div to hide when I mouse ober it and appear again when I put my mouse cursor out of it.Why the div inside keep on blinking when I put my mouse on the inner div?
The second Question: Actually I want to create a tagging effect so when I mouse over the div it will appear. So I change my javascript code to this:
window.onload = function(){
var tag = document.getElementById('tag');
tag.style.visibility = "hidden";
tag.onmouseover = function(){
tag.style.visibility = "visible";
}
tag.onmouseout = function(){
tag.style.visibility = "hidden";
}
}
It doesn't work. I tried another way which I add the visibility: hidden;
inline inside the innerDiv and set the javascript as following:
window.onload = function(){
var tag = document.getElementById('tag');
tag.onmouseover = function(){
tag.style.visibility = "visible";
}
}
It seems like it does not work too, why? This is the fiddle for 1st question: http://jsfiddle.net/uFLPg/