<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(这是我的html代码)
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.(这是我的javsacript代码。) 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?(我希望内部div在鼠标移开时隐藏起来,而当我将鼠标指针移出时再次出现。为什么当我将鼠标放在内部div上时,内部div仍然闪烁?)
The second Question: Actually I want to create a tagging effect so when I mouse over the div it will appear.(第二个问题:实际上,我想创建一个标记效果,因此当我将鼠标悬停在div上时,它将出现。) So I change my javascript code to this:(所以我将我的JavaScript代码更改为:)
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;
(我尝试了另外一种添加visibility: hidden;
) inline inside the innerDiv and set the javascript as following:(内联在innerDiv内部并按如下所示设置javascript:)
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/(这是第一个问题的小提琴: http : //jsfiddle.net/uFLPg/)
ask by dramasea translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…