What's the best jQuery “click a thumbnail and change the main image” module?

后端 未结 8 524
别那么骄傲
别那么骄傲 2021-02-02 02:32

Here\'s what I have (all generated dynamically, if that makes a difference) :

  • A list of images
  • A caption for each image
  • A thumbnail for each imag
8条回答
  •  逝去的感伤
    2021-02-02 03:05

    Most of the answers here are like shooting a fly with a canon !!

    $('#thumbs img').click(function(){
        $('#largeImage').attr('src',$(this).attr('src').replace('thumb','large'));
        $('#description').html($(this).attr('alt'));
    });
    

    this is all you need .. 4 lines of code .

    look here : gallery-in-4-lines

提交回复
热议问题