4

jQuery GalleryView 2.1.1 にアップグレードしましたが、画像の ahref タグをサポートしていないようです。これに対する回避策はありますか? 画像のマウスオーバーでタイトルを表示し、クリックで別のページにリダイレクトできるようにしたい。

4

2 に答える 2

3
$('#gallery .panel img').hover(function() {
    $(this).wrap('<a href="' + this.src + '" target="_blank"/>');
}, function() {
    $(this).unwrap('<a></a>');
});
于 2011-09-11T09:34:50.147 に答える
1

here is what i did: i used the panel-overlay as the object to be clicked.
i added an A tag to it so i can use its href attribute (see bellow)

<li><span class="panel-overlay"><a href="your_link_here" ></a></span><img  src="pic.jpg"  alt=""/></li>  

in the css file i made sure the panel-overlay covered the entire image and made it transparent.also added a hand cursor to it.

.panel .overlay-background { height: 666px; cursor:pointer;background: none; }

finally, inside the page's $(document).ready function i added:

   $(".panel-overlay").click(function() {
    //get the link href 
    var link = jQuery("a", this).attr('href');
    window.location.href = link;
   });  

hope this helps someone out there..
cheers :-)

于 2011-09-11T07:54:32.323 に答える