最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - preventing mouseout event for child node - Stack Overflow

programmeradmin0浏览0评论

I have list of images, on over on image i want to show some information on that image. And mouseout of the info div, same should disappear. Problem is when mouse moves on child tag of info div it fires mouseout even, which should not. And i am using normal JavaScript.

<div id="pop_div" onmouseout="clearinfo()" >
   <img alt="" src="" />
   <p>lines of text</p>
</div>


function clearinfo()
{
  document.getElementById("pop_div").style.dispaly = "none";
}

I have list of images, on over on image i want to show some information on that image. And mouseout of the info div, same should disappear. Problem is when mouse moves on child tag of info div it fires mouseout even, which should not. And i am using normal JavaScript.

<div id="pop_div" onmouseout="clearinfo()" >
   <img alt="" src="" />
   <p>lines of text</p>
</div>


function clearinfo()
{
  document.getElementById("pop_div").style.dispaly = "none";
}
Share Improve this question edited Jul 20, 2009 at 4:15 munity wiki
2 revs, 2 users 73%
vinay 2
  • Why was this post made munity wiki? – rahul Commented Jul 20, 2009 at 4:20
  • You won't get answers because people don't get points on a cWiki... – James Commented Jul 20, 2009 at 6:35
Add a ment  | 

2 Answers 2

Reset to default 5

You can emulate behavior of mouseleave event:

<div id="pop_div" onmouseout="if ((event.relatedTarget || event.toElement) == this.parentNode) clearinfo()" >
   <img alt="" src="" />
   <p>lines of text</p>
</div>

That is the behavior of mouseover. If you were using jQuery however, you could use mouseenter/mouseleave events.

发布评论

评论列表(0)

  1. 暂无评论