[jQuery GalleryView对链接/ href的支持

问题描述 投票:4回答:2

我已经升级到jQuery GalleryView 2.1.1,它似乎不支持图像上的ahref标签。有没有解决方法?我希望能够在鼠标悬停时显示标题并在单击时重定向到另一页。

jquery slideshow galleryview
2个回答
3
投票
$('#gallery .panel img').hover(function() {
    $(this).wrap('<a href="' + this.src + '" target="_blank"/>');
}, function() {
    $(this).unwrap('<a></a>');
});

1
投票

这是我所做的:我使用面板覆盖层作为要单击的对象。我在上面添加了一个A标记,以便可以使用其href属性(请参见下面)

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

在css文件中,我确保面板覆盖物覆盖了整个图像并使其透明。还向其中添加了一个手形光标。

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

最后,在页面的$(document).ready函数内部,我添加了:

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

希望这可以帮助某个人。欢呼:-)

© www.soinside.com 2019 - 2024. All rights reserved.