Jquery 无拇指图像库

Jquery 无拇指图像库,jquery,image,gallery,clone,appendto,Jquery,Image,Gallery,Clone,Appendto,我正在尝试创建一个jQuery图像Gallery我宁愿创建一个,而不是使用插件 我看过几个不同的教程和选择器,每个都使用拇指。 现在我的代码是: $(document).ready(function(){ $('img').click(function(){ $(this).clone().appendTo('#imageViewer').css({"opacity":1,"height":"50%"}); }) }); 问题是,我无法在单击另一个图像时替换该图像。不管怎样,有

我正在尝试创建一个jQuery图像Gallery我宁愿创建一个,而不是使用插件 我看过几个不同的教程和选择器,每个都使用拇指。 现在我的代码是:

$(document).ready(function(){
  $('img').click(function(){
    $(this).clone().appendTo('#imageViewer').css({"opacity":1,"height":"50%"});
  })
});

问题是,我无法在单击另一个图像时替换该图像。不管怎样,有并没有办法只使用常规图像,但使用CSS来缩小它们,即>高度:20%;不透明度:0.2;但当点击时,它们会在页面>高度:50%的div中显示;不透明度:1

尝试将所有图像放入包装器div中。将div设置为position:relative,将图像设置为position:absolute;排名:0;左:0

然后,JavaScript:

var galleryImages = $('#galleryWrapper').find('img');
var firstImage = galleryImages.first(), lastImage = galleryImages.last();
var currentImage=firstImage;

//hide all images but the first
firstImage.siblings().hide();

galleryImages.click(function(){
    //hide the current image
    currentImage.hide();

    //if not last image, show the next
    if (currentImage!=lastImage){
        currentImage=currentImage.next();
        currentImage.show();
    }

    //if last image, go back to the first
    else {
        currentImage=firstImage;
        currentImage.show();
    }
});
请随意调整CSS中图像的大小。

请参阅

HTML

jQuery

编辑:

CSS

Jquery


你可以添加任何你想要的动画。你会如何添加动画,即>幻灯片?
<div id="content">
    <div id="mainImg"><img src="http://youchew.net/wiki/images/9/9c/One.png" /></div>
  <div id="allImg">
    <img src="http://youchew.net/wiki/images/9/9c/One.png" >
    <img src="http://seo-hacker.com/wp-content/uploads/2010/04/22.png" >
    <img src="http://webtrafficnews.com/wp-content/uploads/2012/03/3.png" >

  </div>
  </div>
#content {width:300px;border:solid 1px #f00;overflow:auto; margin:0 auto;}
#allImg {}
#allImg img{ float:left; width:30%;opacity:.5; cursor:pointer; margin:5px}
$(function(){

  $("#allImg").on("click","img",function(){
    $("#mainImg img").prop("src",$(this).prop("src"));

  });

});
#mainImg {width:300px; height:300px;}
$("#allImg").on("click","img",function(){
    newImage = $(this);
    $("#mainImg img").slideUp(500,function()
      {
        $("#mainImg img").prop("src",newImage.prop("src"));

       $("#mainImg img").slideDown(500);
      });

  });