div onmouseout无法按预期工作

编程入门 行业动态 更新时间:2024-10-10 16:22:43
本文介绍了div onmouseout无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

文字和示例代码改编自 http:// www。 webdeveloper/forum/archive/index.php/t-65078.html ,可能无法反映实际问题:

Text and sample code adapted from www.webdeveloper/forum/archive/index.php/t-65078.html, may not reflect actual question:

我有一个div然后是div里面有一个嵌套表:父div之外还有一些div。

I have a div and then a div with a nested table inside it: also there is some div outside the parent div.

<div onmousemove="move()" onmouseout="out()"> <div id="dvRep"> </div> <table> <tr><td>ITEM 1</td></tr> <tr><td>ITEM 2</td></tr> <tr><td>ITEM 3</td></tr> <tr><td>ITEM 4</td></tr> <tr><td>ITEM 5</td></tr> </table> </div> <div id="divChartPopupMenu"> Hide me. </div>

每当我在div中移动鼠标时,它都会正确调用移动功能,但 onmouseout 属性不像我想的那样工作。我认为只有将鼠标移离div时才会调用 out()函数,但是 out()

Whenever i move my mouse within the div it correctly calls the move function, but the onmouseout attribute doesn't work like i thought. i thought that the out() function would only be called if you moved your mouse off the div, but out() is called whenever i move off one of the table rows. so if my mouse is on a row and i move to the next row it calls out(). i want out() to be called only when the user moves off the entire div. any ideas?

我正在尝试的是我正在隐藏另一个div的功能。

What i am trying is on out function i am hiding another div.

推荐答案

我建议你阅读这篇关于javascript事件的3个阶段的文章。 www.quirksmode/js/events_order.html

i suggest you to read this article on 3 phases of javascript events. www.quirksmode/js/events_order.html

在函数移出或移出时,你可以查看是否srcElement(IE)或目标(W3C)有一个名为dvRep的id ..

in the function move or out, you can check if the srcElement(IE) or target(W3C) has an id called dvRep..

它应该是这样的:

function out(event) { event.stopPropagation(); //cancel bubbling ele = event.target || event.srcElement if (ele.id === "dvRep"){ //your code } }

更多推荐

div onmouseout无法按预期工作

本文发布于:2023-11-25 11:34:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629585.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作   div   onmouseout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!