关于onmouseover和onmouseout在嵌套标签中的问题!!!! function fnMouseOutMe(){ if(event.srcElement.TagName=="INPUT") return false; else //.....} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样可不行,即使不考虑input,当鼠标移到tr 或 td上的时候,table的onmouseout事件也会被触发啊!!!!!! onmouseout和onmouseover事件是冒泡的,也就是说在TABLE中会接收到内部元素的事件,使用setCapture可以解决,但会比较烦,因为setCapture的时机难于确定。这时更好的方法是在事件处理器中检查 event.srcElement,在您的实例中可以这样:if(event.srcElement.nodeName!='TABLE')return; 把table嵌在<div>中如何?然后:function fnMouseOutMe(){ if(event.srcElement.TagName=="DIV") return false; else //.....} imafool(只为了她) 说的 “onmouseout和onmouseover事件是冒泡的...”对我有点启发 其实我只想在5.5以下的版本中能够使用同 onmouseenter 事件的功能!!!!!!在5.5中,使用 onmouseenter 就完全可以解决我的问题了! 哦原来有onmouseenter啊?我还不知道呢学到东西了 正如imafool所说,是IE的事件冒泡机制引起的问题,试试这样<table onmouseover=fnMouseOverMe() onmouseout=if(!this.contains(event.srcElement)){fnMouseOutMe()}><tr><td><input type=text style="width:100%;height:100%"></td></tr></table> 我发现,通过使用下面的方法我已实现我所想要的功能:<DIV onmouseover=over(this) onmouseout=out(this) style="width:200px;height:100px;background-color:red"><INPUT TYPE="text" NAME=""><INPUT TYPE="text" NAME=""></DIV><script>function over(o) { if (!(o.contains(window.event.fromElement))) { alert("Enter"); }}function out(o) { if (!(o.contains(window.event.toElement))) { alert("Out Now"); }}</script> jQuery动态添加的HTML,获取参数问题! 如何使用js实现文件下载 请教一个包含换行的正则表达式的书写。还请忙忙 获取地址栏中的URL地址 如何获得form引用 求javascript语法检查工具 脚本写的IE右键助手 怎么判断鼠标当时位置在一个容器里,比如table? 请教有关网络视频的技术 easyui datagrid detailview 如何实现两个文本框联动? 如何用javascript将文本框中的字符串转换成整形
然后:
function fnMouseOutMe()
{
if(event.srcElement.TagName=="DIV")
return false;
else
//.....
}
在5.5中,使用 onmouseenter 就完全可以解决我的问题了!
原来有onmouseenter啊?
我还不知道呢
学到东西了
<tr>
<td>
<input type=text style="width:100%;height:100%">
</td>
</tr>
</table>
<DIV onmouseover=over(this) onmouseout=out(this) style="width:200px;height:100px;background-color:red">
<INPUT TYPE="text" NAME="">
<INPUT TYPE="text" NAME="">
</DIV>
<script>
function over(o) {
if (!(o.contains(window.event.fromElement))) {
alert("Enter");
}
}function out(o) {
if (!(o.contains(window.event.toElement))) {
alert("Out Now");
}
}
</script>