Jquery循环显示图片


代码---------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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 runat="server">
    <title></title>

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

    <script type="text/javascript">
        $(document).ready(function() {
            //可以在这里动态的输出图片 当然由于本人艺浅 这里的ID都写死了 但是这没什么影响
            readys();
        });
        function showimg() {
            var id_temp = $("#Hidden1").val();
            var obj = $("#" + id_temp);
            $("#ids img").css("border", "solid 0px white");
            var newobj = $("#img" + (parseInt(id_temp) + 1))
            if (typeof (newobj.attr("id")) == "undefined") {
                readys();
                return;
            }
            newobj.css("border", "solid 1px red");
            var vals = newobj.attr("src");
            $("#main").attr("src", vals);
            $("#main").width(270);
            $("#main").height(240);
            $("#Hidden1").val((parseInt(id_temp) + 1));
        }
        function readys() {
            var obj = $("#ids img:first");
            obj.css("border", "solid 2px red");
            var vals = obj.attr("src");
            $("#main").attr("src", vals);
            $("#main").width(270);
            $("#main").height(243);
            $("#Hidden1").val("1");
        }
        window.setInterval("showimg()", 1000);
    </script>

    <style type="text/css">
        div img
        {
            float: left;
            width: 122px;
            height: 60px;
            margin: 4px,4px,0px,4px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <input id="Hidden1" type="hidden" />
    <div style="width: 400px; position: absolute; height: 236px; float: left; background-color: #FFCC99;
        padding-bottom: 60px; padding-top: 60px;">
        <div id="ids" style="width: 126px; height: 240px">
            <img id="img1" src="images/image1.jpg" alt="Title for an image" />
            <img id="img2" src="images/image2.jpg" alt="Title for an image" />
            <img id="img3" src="images/image3.jpg" alt="Title for an image" />
            <img id="img4" src="images/image4.jpg" alt="Title for an image" />
            <div style="position: absolute; float: left; width: 274px; height: 240px; left: 126px;
                margin-left: 5px;">
                <img id="main" alt="" src="" />
            </div>
        </div>
    </div>
    </form>
</body>
</html>

--图片可以自己改的啊jquery的类库大家都有吧

posted @ 2011-03-17 18:46  Ganler1988  阅读(708)  评论(0编辑  收藏  举报