jquey animate 实现切换图片效果

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication57.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        #prev{ cursor:pointer; margin-top:136px;}
        #next{ cursor:pointer; margin-top:136px;}
        .prev_content{ width:17px; height:296px; float:left;}
        .next_content{ width:17px; height:296px; float:left;}
        .v_content { position:relative; overflow:hidden; width:412px; height:296px; margin:0px; float:left;}
        .v_content_list { position:absolute; width:1236px;top:0px; left:0px; }
        .v_content_item { float:left;}
    </style>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        $(function () {
            var item_length = $('div.v_content_item').length;
            var item_index = 1;
            var v_content_width = $('div.v_content').width();
            $('#prev').click(function () {//Show the previous chart. If it is the first chart, then show the last one.
                if (!$('div.v_content_list').is(':animated')) {
                    if (item_index == 1) {
                        $('div.v_content_list').animate({ left: '-=' + v_content_width * (item_length - 1) }, 'slow');
                        item_index = item_length;
                    }
                    else {
                        $('div.v_content_list').animate({ left: '+=' + v_content_width }, 'slow');
                        item_index--;
                    }
                }
            });
            $('#next').click(function () {//Show the next chart. If it is the last chart, then show the first one.
                if (!$('div.v_content_list').is(':animated')) {
                    if (item_index == item_length) {
                        $('div.v_content_list').animate({ left: '+=' + v_content_width * (item_length - 1) }, 'slow');
                        item_index = 1;
                    }
                    else {
                        $('div.v_content_list').animate({ left: '-=' + v_content_width }, 'slow');
                        item_index++;
                    }
                }
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="prev_content">
        <img id="prev" src="Image/prev.png" alt="" />
    </div>
    <div class="v_content">
        <div class="v_content_list">
            <div class="v_content_item"><img id="Img1" src="Image/1.png" alt="" /></div>
            <div class="v_content_item"><img id="Img2" src="Image/2.png" alt="" /></div>
            <div class="v_content_item"><img id="Img3" src="Image/3.png" alt="" /></div>
        </div>
    </div>
    <div class="next_content">
        <img id="next" src="Image/next.png" alt="" />
    </div>
</asp:Content>


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值