jquery鼠获取标滚轮次数(1)
2015-06-14 13:31
633 查看
这里使用了mousewheel的jquery插件。网址是:http://www.jq22.com/jquery-info805
功能描述:获取鼠标滚动次数。
所需要的引用的文件是:
1.jquery.min.js
2.jquery-mousewheel.js
结果图片:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201908/30/c533e5485315aa848cca6a8e4bdb8d46)
html代码:
<!DOCTYPE html>
<html lang="zh-CN">
<meta http-equiv="Content-type" content="text/html" charset="utf-8" >
<head>
<title>获取滚轮次数</title>
<style>
.box { width: 600px; height: 300px; background-color: #eed; }
</style>
</head>
<body>
<div class="box">
<p>滚动鼠标为+1或者-1</p>
<span>0</span>
</div>
</body>
<script type="text/javascript" src="script/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="script/jquery-mousewheel.js"></script>
<script type="text/javascript" src="script/test.js"></script>
</html>
test.js代码:
$(function(){
var len = 0;
var $box = $('.box');
var $text = $('.box span');
$box.mousewheel(function(y){
len += y;
if(y>0){
//alert(len);
$text.html(len);
}else{
$text.html(len);
}
});
});
功能描述:获取鼠标滚动次数。
所需要的引用的文件是:
1.jquery.min.js
2.jquery-mousewheel.js
结果图片:
html代码:
<!DOCTYPE html>
<html lang="zh-CN">
<meta http-equiv="Content-type" content="text/html" charset="utf-8" >
<head>
<title>获取滚轮次数</title>
<style>
.box { width: 600px; height: 300px; background-color: #eed; }
</style>
</head>
<body>
<div class="box">
<p>滚动鼠标为+1或者-1</p>
<span>0</span>
</div>
</body>
<script type="text/javascript" src="script/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="script/jquery-mousewheel.js"></script>
<script type="text/javascript" src="script/test.js"></script>
</html>
test.js代码:
$(function(){
var len = 0;
var $box = $('.box');
var $text = $('.box span');
$box.mousewheel(function(y){
len += y;
if(y>0){
//alert(len);
$text.html(len);
}else{
$text.html(len);
}
});
});
相关文章推荐
- jQuery中$(function()与(function($)等的区别详细讲解
- Jquery ui autocomplete简单api
- jquery源码之缓存系统--$.data
- javascript学习笔记-2:jQuery中$("xx")返回值探究
- 关于Jquery的serialize()使用注意
- JQuery :Not() Selector Example
- jQuery html() example
- 浅谈Jquery中的bind(),live(),delegate(),on()绑定事件方式
- jQuery - slice( start, [end] ) Method
- 关于HTML5、Jquery、Phonegap跨域问题的研究
- jquery mobile 的优缺点
- jquery 初步(四)内容过滤器
- jquery 初步(三) 基本过滤器
- jQuery 各个版本下载
- Jquery的val()方法
- 推荐十个最新免费的 jQuery 表格插件
- jQuery 属性操作方法
- Jquery easyui开启行编辑模式增删改操作
- JQuery
- JQuery上传插件Uploadify使用详解