缩略图上的jquery灯箱单击更改主图像

时间:2013-04-10 14:06:15

标签: jquery html fancybox lightbox

我正在使用jquery.fancybox-1.3.4.pack.js用于灯箱,在该灯箱中我想使用一些jquery。基本上,它是左边的产品灯箱,有一个主图像,右边有3-4个缩略图。

我希望当用户点击缩略图时,主图像应该根据拇指进行更改。

<div class="product-lightBox">
            <img src="images/lb-brand-logo.jpg">
            <div class="product">

                <div class="left">
                    <img src="images/lb-product-img.jpg">
                    <img src="images/lb-product-img.jpg">
                     <img src="images/lb-product-img.jpg">
                </div>

                <div class="right">
                    <div class="row">
                        <h5>Product<span>2088</span></h5>
                    </div>
                    <div class="row">
                        <h5>Color</h5>
                        <ul class="color">
                            <li><a href="#"><img src="images/lb-thumb-img1.jpg"><span>Black<img src="images/color-pointer.png"></span></a></li>
                            <li><a href="#"><img src="images/lb-thumb-img2.jpg"><span>Red<img src="images/color-pointer.png"></span></a></li>
                            <li><a href="#"><img src="images/lb-thumb-img3.jpg"><span>Brown<img src="images/color-pointer.png"></span></a></li>
                        </ul>
                    </div>
                    <div class="row">
                        <h5>Size<span>5 - 11</span></h5>
                    </div>
                    <div class="row">
                        <h5>Prize<span class="price">INR 999</span></h5>
                    </div>
                    <div class="des">
                        <h4>Description</h4>
                        <div class="clear"></div>
                        <div class="detail">
                            <p>This is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum</p>
                        </div>
                    </div>
                </div>

                <div class="clear"></div>

                <img src="images/lb-social-icons.jpg">

            </div>
        </div>

1 个答案:

答案 0 :(得分:0)

对HTML进行一些修改:

向缩略图添加数据属性

<img src="images/lb-thumb-img1.jpg" data-image="images/lb-big-img1.jpg">

然后做这样的事情:

$(".color img").click(function()
{
    var image = $(this).data("image");
    $(".left img").attr("src", image);
});