手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery实现上下左右滑动的方法
jquery实现上下左右滑动的方法
摘要:本文实例讲述了jquery实现上下左右滑动的方法。分享给大家供大家参考。具体实现方法如下:复制代码代码如下:无标题文档$(document)...

本文实例讲述了jquery实现上下左右滑动的方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>无标题文档</title>

<script type="text/javascript" src="jquery-1.11.2.js"></script>

<script type="text/javascript">

$(document).ready(function(){

$("#btn").unbind().click(function(){

$("#first").hide();

$("#sec").css("left","-200px").animate({"left":"0px"},500).show();

});

$("#btn2").unbind().click(function(){

$("#sec").hide();

$("#first").css("left","200px").animate({"left":"0px"},500).show();

});

$("#btn3").unbind().click(function(){

$("#first").hide();

$("#sec").css("top","200px").animate({"top":"0px"},500).show();

});

$("#btn4").unbind().click(function(){

$("#sec").hide();

$("#first").css("top","-200px").animate({"top":"0px"},500).show();

});

});

</script>

</head>

<body>

<div>

<div id="first">

<p>第一页</p>

<p>第一页</p>

<p>第一页</p>

<p>第一页</p>

<p>第一页</p>

</div>

<div id="sec">

<p>第二页</p>

<p>第二页</p>

<p>第二页</p>

<p>第二页</p>

<p>第二页</p>

</div>

</div>

<div>

<input type="button" value="向右滚动" id="btn"/>

<input type="button" value="向左滚动" id="btn2"/>

<input type="button" value="向上滚动" id="btn3"/>

<input type="button" value="向下滚动" id="btn4"/>

</div>

</body>

</html>

特别要注意:代码中的position:absolute;一定要加上,否则不会出现效果。

希望本文所述对大家的jQuery程序设计有所帮助。

【jquery实现上下左右滑动的方法】相关文章:

jquery简单实现外部链接用新窗口打开的方法

jQuery仿gmail实现fixed布局的方法

jquery实现图片左右切换的方法

JavaScript实现鼠标滑过处生成气泡的方法

jQuery插件bgStretcher.js实现全屏背景特效

js实现字符串转日期格式的方法

jQuery判断一个元素是否可见的方法

jQuery子窗体取得父窗体元素的方法

JS实现窗口加载时模拟鼠标移动的方法

js实现点击链接后延迟3秒再跳转的方法

精品推荐
分类导航