国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jquery實現上下左右滑動的方法

2019-11-20 13:11:34
字體:
來源:轉載
供稿:網友

本文實例講述了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 style="width:200px; height:200px;">
<div id="first" style="text-align:center; width:200px; height:200px;position:absolute;">
    <p>第一頁</p>
        <p>第一頁</p>
        <p>第一頁</p>
        <p>第一頁</p>
        <p>第一頁</p>
    </div>
    <div id="sec" style="text-align:center; width:200px; height:200px; display:none;position:absolute;">
        <p>第二頁</p>
        <p>第二頁</p>
        <p>第二頁</p>
        <p>第二頁</p>
        <p>第二頁</p>
    </div>
</div>
<div style="width:200px; height:50px;">
<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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平昌县| 乌拉特后旗| 阜阳市| 牡丹江市| 亚东县| 阜南县| 玉环县| 永仁县| 锡林浩特市| 安义县| 祁门县| 荣成市| 句容市| 通化县| 日土县| 文成县| 乐山市| 诸暨市| 泸定县| 正镶白旗| 元谋县| 安平县| 池州市| 特克斯县| 光泽县| 开江县| 石渠县| 安乡县| 封开县| 蒙山县| 彭水| 麦盖提县| 凭祥市| 屏南县| 隆化县| 荥阳市| 江川县| 同江市| 原阳县| 临澧县| 松潘县|