首页 / 脚本样式 / jQuery / jQuery实现用鼠标拖拽进行翻页
jQuery实现用鼠标拖拽进行翻页2011-11-01 博客园 朱祁林在以前的一篇文章中涉及到自定义的分页: http://www.cnblogs.com/zhuqil/archive/2010/01/02/custompagingandlisting.html,今天很郁闷,在 其中加入一个小功能:用你的鼠标拖拽进行分页:鼠标向右拖翻到后一页;鼠标向左拖,翻到前一页。首先下载最新版本的jQuery 和jGesture 插件。在以前的分页源程序中加入下面代码。js<script src="Scripts/jquery-1.3.1.js" type="text/javascript"></script>
<script src="Scripts/jgesture-1.0.3.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
$().gesture(function(gs) {
var gestureName = gs.getName();
var intPageIndex = document.getElementById ("txtHidPageIndex").value
if (gestureName == "right") {
doPaging(++intPageIndex);
}
else if (gestureName == "left") {
if (intPageIndex > 1)
doPaging(--intPageIndex);
}
});
});
</script>
用gestureName进行判断,如果鼠标向右拖拽,intPageIndex++,如果鼠标向左拖拽,intPageIndex-- 。出处:http://zhuqil.cnblogs.com代码: http://files.cnblogs.com/zhuqil/custompagingandlisting.rar本文配套源码:http://www.bianceng.net/javascript/201212/700.htm