admin管理员组文章数量:1318579
On mouseover
can this div be attached to the mouse pointer so that its contents are shown on mouseover?
<div id='show' style='display:none;'></div>
If so how is this done?
On mouseover
can this div be attached to the mouse pointer so that its contents are shown on mouseover?
<div id='show' style='display:none;'></div>
If so how is this done?
Share Improve this question edited Feb 5, 2010 at 13:21 Sampson 269k76 gold badges545 silver badges568 bronze badges asked Feb 5, 2010 at 11:30 HulkHulk 34.2k64 gold badges150 silver badges217 bronze badges2 Answers
Reset to default 2<div onmousemove="position();" onmouseout="hide();">abc</div>
<div id="tip" style="position: fixed; visibility: hidden;">that's abc!</div>
<script type="text/javascript">
function position() {
var d = document.getElementById('tip');
d.style.visibility = 'visible';
d.style.left = event.screenX + 'px';
d.style.top = event.screenY + 'px';
}
function hide() {
document.getElementById('tip').style.visibility = 'hidden';
}
</script>
When the user mouses over the "abc" div, the "that's abc!" div is shown next to the mouse cursor (and follows it).
Try this:
<div id='show' onmouseover="this.style.display = 'block';"></div>
But for that to work, the div should be visible first. However, if the div is hiddne (display:none) then onmoueever event won't be able to find the div and no event will be triggered on it. Having said that, try this which uses visibility property.
<div id='show' onmouseover="this.style.visibility = 'visible';" onmouseout="this.style.visibility = 'hidden';"></div>
本文标签: javascriptShow DIV on MouseOverStack Overflow
版权声明:本文标题:javascript - Show DIV on MouseOver - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742039057a2417467.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论