jquery mouseover与mouseenter区别
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="../Packages/jQuery.1.8.3/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
x = 0;
y = 0;
$(document).ready(function () {
$("div.over").mouseover(function () {
$(".over span").text(x += 1);
});
$("div.enter").mouseenter(function () {
$(".enter span").text(y += 1);
});
});
</script>
</head>
<body>
<p>不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件。</p>
<p>只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件。</p>
<div class="over" style="background-color: lightgray; padding: 20px; width: 40%; float: left">
<h2 style="background-color: white;">被触发的 Mouseover 事件:<span></span></h2>
</div>
<div class="enter" style="background-color: lightgray; padding: 20px; width: 40%; float: right">
<h2 style="background-color: white;">被触发的 Mouseenter 事件:<span></span></h2>
</div>
</body>
</html>
mouseleave与mouseout与之对应。
jquery中可用hover替换以上操作
x = 0;
y = 0;
$(document).ready(function () {
$("div.over").hover(
function () { $(".over span").text(x += 1); },
function () {$(".enter span").text(y += 1);}
)
});
hover(enter,leave)模拟光标悬停事件,光标移到元素上触发enter,移除触发leave
hover(enter,leave)是用于替换bind("mouseenter")和bind("mouseleave"),不是用于替换bind("mouseover")和bind("mouseout")
转载:http://blog.csdn.net/ocean1010/article/details/7394599
jquery mouseover与mouseenter区别的更多相关文章
- jQuery mouseover与mouseenter,mouseout与mouseleave的区别
mouseover与mouseenter 不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件. 只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件. mouseou ...
- 曾经跳过的坑----jQuery mouseover与mouseenter,mouseout与mouseleave的区别
mouseover与mouseenter 不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件. 只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件. mouseou ...
- jQuery mouseover与mouseenter的区别
在我们的页面中经常会用到mouseover与mouseout事件来给页面添加更好的渲染效果,但如果触发mouseover事件的元素有子元素的话,会造成闪烁的效果,看着很不舒服,这是因为mouseove ...
- mouseleave,mouseout 和mouseover ,mouseenter区别
鼠标离开事件: mouseleave:只有鼠标离开指定元素时才会触发; mouseout 鼠标离开指定元素或内部子元素都会触发; 鼠标在上事件: mouseover:只有鼠标进入指定元素时才会触发; ...
- mouseover与mouseenter区别
学习笔记. mouseover:在鼠标移入元素本身或者子元素时都会触发事件,相当于有一个冒泡过程.而且在鼠标移入子元素中时,父元素会显示离开的状态:相应的,当鼠标从子元素移入父元素,子元素也会显示离开 ...
- jQuery里的mouseover与mouseenter事件类型区别
JQ里面有mouseover和mouseenter 2个事件类型干着差不多的活,用不好经常出现些小问题. 今天我解释一下原理: 事件类型翻译: mouseover 鼠标移上 mouseenter 鼠 ...
- jquery的hover mouseover mouseout mouseenter mouseleave的区别
jquery的hover mouseover mouseout mouseenter mouseleave的区别 1.mouseover mouseout mouseover - 鼠标指针经过任何子元 ...
- jQuery关于mouseover和mouseenter的区别
原生的mouseenter是dom3级的事件,对于jQuery等一些框架已经实现了这个事件.但是它到底跟mouseover有什么区别? jQuery在实现这两个事件的时候,mouseover支持事件冒 ...
- jquery中mouseover和mouseenter的区别
jquery中mouseover和mouseenter的区别 一.总结 一句话总结: 见名知意:enter(进入)和over(在上方)的意思好好思考一下 mouseover就是从子元素回到自己的时候也 ...
随机推荐
- django-templates过滤器
常用内置过滤器: 过滤器会更改量或便签参数的值: title过滤器: {{ django|title }} 在下列context中 {'django': 'the web framework for ...
- JS 回调函数、立即执行、for块作用域、try/catch、let、垃圾收集 p3
限于时间关系,加上有些倦意,简单的记录下一些要点: 1.回调函数:就你把函数当成参数传给另一个函数,这个函数在某个时间段会执行这个函数.
- vertical-align 详解
vertical-align用来设置垂直对齐方式,所有垂直对齐的元素都会影响行高 值: baseline | sub | super | top | text-top | middle | botto ...
- 安装google,多试试
对于谷歌Chrome32位版本,使用如下链接: wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.de ...
- android控件跟随手势滑动改变位置
要求:1.通过手指移动来拖动图片 2.控制图片不能超出屏幕显示区域 技术点:1.MotionEvent处理2.对View进行动态定位(layout) activity_main.xml: < ...
- Flex自动回收导致监听不到ModuleEvent.READY事件
Flex中可以动态载入模块,以达到延迟加载,减小主程序体积的效果.通常可以使用如下代码: var iminfo:IModuleInfo = ModuleManager.getModule(" ...
- 8.2,常用模块介绍:sys,os,time,random
sys: 介绍:主要包含涉及python编译器与系统交互的函数. 常用函数: import sys print(sys.argv)#本文件名,已经运行该程序时的参数 #[如在命令窗口中python3 ...
- 让 Angular 应用动起来!
[编者按]本文主要通过生动的实例,介绍为 Angular 应用添加动画的原理与过程.文章系国内 ITOM 管理平台 OneAPM 编译呈现. 我们知道,Angular 应用在更新 DOM 时,会直接将 ...
- WordCount系统分析与设计作业
Gitee项目地址 https://gitee.com/gitdq/homework psp表 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划 10 10 · ...
- Oracle EBS AR 收款调整取值
SELECT ct.trx_number ,adj.adjustment_number ,ad.amount_dr ,ad.amount_cr ,ad.source_table ,ad.source_ ...