
jquery中有2个对应的事件,那就是mouseover与mouseout。mouseover就是移动到元素触发的事件,mouseout就是离开元素触发事件。
示例:
当鼠标从元素上移开时,改变元素的背景色:
jQuery 代码:
$("div")mouseout(function(){
$("div")css("background-color","#E9E9E4");
});
$("div")mouseover(function(){
$("div")css("background-color","yellow");
});
ul绑定mousewheel鼠标滚动事件(火狐用DOMMouseScroll)
取消默认动作,eventpreventDefault()(IE:windoweventreturnValue=false),这样滚轮滚动后就不会滚动页面了。
根据滚轮滚动的方向对ul内容进行控制,获取滚轮方向用eventwheelDelta,大于0为向上滚,小于0向下滚(火狐eventdetail,方向刚好相反,大于0向下),再更改ul的scrollLeft值即可以模拟滚轮滚动效果了。
给你改了一下 试试呗 用 epageX epageY 也行吧 省的那么麻烦
$(document)ready(function(){
$("#img")mousemove(function(e){
var widthh=eoriginalEventx-$(this)offset()left||eoriginalEventlayerX-$(this)offset()left||0;//
var heightt=eoriginalEventy-$(this)offset()top||eoriginalEventlayerY-$(this)offset()top||0;//
$('#container')text("的宽度:" + widthh +"<br>的高度:"+heightt);
})mouseout(function(){
$("#tooltip")remove();
thistitle = thismyTitle;
})
});
</script>
</head>
<body>
<img id="img" width="200" height="200" src="images/starpng"></img>
<div id="container" style="width: 400px; height: 200px; background-color: green;">
</div>
</body>
完全不需要js实现,除非你要兼容IE6
只要把sc的样式
position:absolute;改为
position:fixed;即可
以上就是关于请教一个问题,关于jquery判断鼠标移动到当前div和离开div的全部的内容,包括:请教一个问题,关于jquery判断鼠标移动到当前div和离开div的、怎么用jquery或者javascript让横向滚动条跟着鼠标滚球滚动、jquery里鼠标移动显示图片当前坐标的位置等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)