jQuery点击小图片显示大图片

 

<style type="text/css">
        .warp
        {
            width: 487px;
            height: 194px;
            overflow: hidden;
            border: solid 1px #ccc;
            position: relative;
            top: 0px;
            left: 0px;
            background-color: #fafafa;
        }
        .warp img
        {
            border-width: 0px;
            cursor: pointer;
            position: relative;
            top: 0px;
            left: 0px;
        }
        .imgBig
        {
            float: left;
            width: 360px;
            height: 190px;
            padding: 2px;
        }
        .imgLittle
        {
            float: right;
            width: 108px;
            height: 57px;
            padding: 6px 5px 0 10px;
            clear: right;
        }
    </style>
    <script src="Jquery1.7.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            var $warp = $("#warp");
            $warp.IsRunning = false;
            var seconds = 500;
            $warp.children("img").click(function () {
                if ($warp.IsRunning) { return; }
                $warp.IsRunning = true;
                var $imgs = $("#warp").children("img");

                $imgs.eq(2).css("marginTop", "63px").animate({ marginTop: "0px" }, { duration: seconds });
                $imgs.eq(0).css({ position: "absolute", opacity: "0.5" }).animate({ width: "108px", height: "57px", left: "372px", top: "126px", opacity: "1" }, { duration: seconds });

                $imgs.eq(1).css({ position: "absolute", left: "372px", top: "6px", opacity: "0.2", clear: "none" }).animate({ width: "360px", height: "190px", left: "-9px", top: "-5px", opacity: "1" }, { duration: seconds, complete: function () {
                    $imgs.eq(0).appendTo($("#warp"));
                    $imgs.eq(0).removeAttr("style").removeClass("imgBig").addClass("imgLittle");
                    $imgs.eq(1).removeAttr("style").removeClass("imgLittle").addClass("imgBig");
                    $warp.IsRunning = false;
                }
                });
            });
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="warp" id="warp">
        <img src="images/look1.jpg" alt="" class="imgBig" />
        <img src="images/look2.jpg" alt="" class="imgLittle" />
        <img src="images/look3.jpg" alt="" class="imgLittle" />
        <img src="images/look4.jpg" alt="" class="imgLittle" />
    </div>
    </form>
</body>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值