0

サムネイルの画像属性を使用して、画像全体の下にキャプションを作成しようとして、作成した画像ギャラリー関数をいじっていました。特にalttitle。サムネイル ギャラリー側には問題はありません。一方、キャプションはundefinedを返し、完全な画像の下ではなく、最初のサムネイルの下に表示されます。

$('.gallery li img').hover(function(){
        var $viewer = $(this).parents('.viewer');
      $('.full-img',$viewer).attr('src',$(this).attr('src').replace('thumb/', ''));
      $('.full-img',$viewer).attr('alt',$(this).attr('alt').replace('thumb/', ''));
         var caption_alt = $('.full-img',$viewer).attr('alt');
         var caption_title = $('.full-img',$viewer).attr('title');
      if (caption_alt !== "" && caption_title !== ""){('.full-img', $viewer).after('<p class="captiontitle">' + caption_title + '</p>' + '<p class="captionalt">' + caption_alt + '</p>')}
});
4

1 に答える 1

0

これを試して

$('.gallery li img').hover(function(){
        var $viewer = $(this).parents('.viewer');
        $('.full-img',$viewer).attr('src',$(this).attr('src').replace('thumb/', ''));
        $('.full-img',$viewer).attr('alt',$(this).attr('alt').replace('thumb/', ''));//missed . here
         var caption_alt = $('.full-img',$viewer).attr('alt');//missed . here
         var caption_title = $('.full-img',$viewer).attr('title');//missed . here
      if (caption_alt !== "" && caption_title !== ""){('.full-img', $viewer).after('<p class="captiontitle">' + caption_title + '</p>' + '<p class="captionalt">' + caption_alt + '</p>')}
}); //missed a . and an ending double quote "
于 2012-09-13T21:59:38.620 に答える