您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> .NET >> 怎么解决mouseover的冒泡事件

怎么解决mouseover的冒泡事件

来源:网络整理     时间:2016/6/29 8:13:46     关键词:

关于网友提出的“ 怎么解决mouseover的冒泡事件”问题疑问,本网通过在网上对“ 怎么解决mouseover的冒泡事件”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 怎么解决mouseover的冒泡事件
描述:

我封装的这个方法老是多次执行,大师们帮我指点一下怎么解决

HTML代码

无标题文档 $(function(){  $('.a').mouseover(function(){  offset = $(this).offset();  xx = offset.left;  yy = offset.top;  $('#intro').slideToggle(500);
 document.getElementById("intro").style.left = xx +'px';  document.getElementById("intro").style.top = yy +'px';  document.getElementById("intro").innerHTML ="要正确啊啊";  });
 $('.a').mouseout(function(){  $('#intro').fadeOut('normal');
 document.getElementById("intro").innerHTML ="";  })  })

<> <>
 style='color: #FFF; position: absolute;   left: 0px; top: 0px; display: none; background-color: #000;
 /*background-color: rgb(228, 246, 255);*/ border: 1px rgb(91, 185, 233) solid;   width: 100px; height: 150px; overflow: hidden; z-index:9999; filter: alpha(opacity = 80); opacity: 0.8; text-align: center;'>  
无标题无标题无标题无标题 无标题无标题无标题无标题 无标题无标题无标题无标题

无标题无标题无标题无标题


解决方案1:

var timeObj;     $('.a').mouseover(function(){         clearTimeout(timeObj);
        var $this = $(this);         timeObj = setTimeout(function(){                     var offset = $this.offset(),
/>                 xx = offset.left,
                yy = offset.top;
            $('#intro').slideToggle(500).css({left: xx, top: yy}).html("要正确啊啊");                     }, 600);     });     $('#intro').mouseout(function(){                 $(this).fadeOut('normal').html("");    <>     })

解决方案2:

引用 5 楼 naonaoye 的回复:
JScript code
event.stopPropagation()
event.cancelBubble=true; 应该是这2个方法,一个是IE特有的,一个不支持IE,注意下兼容性
刚刚试了下用event.cancelBubble=true就可以了
以上介绍了“ 怎么解决mouseover的冒泡事件”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2148063.html

上一篇win7 上传文件错误,没有提示错误,但是文件传不上去 下一篇如何把数据库内容读到xml文件里?类似于相册是flash+xml,通过xml文件配置图片,但是图片我想从数据库中读出来,请问如何实现?

相关图片

相关文章