2012-02-05 6 views

答えて

2

、代わりにプラグインの例を次のようにHTMLを行います

$(function() { 
    // let's set a variable as our img attr title 
    var title = $("img").attr('title'); 

    var move = -15; 

    //zoom percentage, 1.2 =120% 
    var zoom = 1.2; 

    //On mouse over those thumbnail 
    $('.item').hover(function() { 
     //Grab title from title attr 
      $("h2").hide().append(title).fadeIn('slow'); 

     //Set the width and height according to the zoom percentage 
     width = $('.item').width() * zoom; 
     height = $('.item').height() * zoom; 

     //Move and zoom the image 
     $(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200}); 

     //Display the caption 
     $(this).find('div.caption').stop(false,true).fadeIn(200); 
    }, 
    function() { 
     //Remove title 
     $("h2").empty(); 

     //Reset the image 
     $(this).find('img').stop(false,true).animate({'width':$('.item').width(), 'height':$('.item').height(), 'top':'0', 'left':'0'}, {duration:100}); 

     //Hide the caption 
     $(this).find('div.caption').stop(false,true).fadeOut(200); 
    }); 
}); 

<div class="item"> 
    <a href="link"> 
     <img src="link img" title="your title" width="125" height="125"/> 
     <div class="caption"> 
      <h2></h2> 
     </div> 
    </a> 
</div> 

が、これは説明するためのコメントで、あなたが必要とする更新jQueryのです

実例:http://jsfiddle.net/u2HxY/40/

1

alt属性を取得し、キャプションHTMLに挿入します。そのプラグインのコードに従うことにより

$('#captionID').html($('#imageID').attr('alt')); 
+0

を投稿 –

0

これを使用してください。

$('#imgSelector').attr('title') 

または

$('#imgSelector').attr('alt') 
関連する問題