我正在使用这个http://spaceforaname.com/galleryview/,
我需要插入每个图片的链接,所以我添加了如下链接,但它不起作用。有没有什么方法可以让我点击图片跳转到某个地方?
<ul id="myGallery">
<li><a href="#"><img src="http://www.spaceforaname.com/galleryview/img/photos/bp1.jpg" alt="Lone Tree Yellowstone" /></a>
<li><a href="#"><img src="http://www.spaceforaname.com/galleryview/img/photos/bp1.jpg" alt="Lone Tree Yellowstone" /></a>
</ul>发布于 2013-05-15 22:25:41
需要修改Galleryview的.js:
this.customlink = img.attr('customlink');
this.haslink = img.attr('haslink');
var address = "'" + gvImage.customlink + "'";
var js = "window.location.assign(" + address + ");";
if(gvImage.haslink=='true') {img.attr("onclick", js);}
<ul id="myGallery">
<li><img haslink="true" customlink="somelink" src="images/1.jpg" alt="Lone Tree Yellowstone" />
<li><img haslink="true" customlink="somelink" src="images/2.jpg" alt="Lone Tree Yellowstone" />
</ul>
如果您希望将图库的图像作为链接,请设置"haslink=true“。"customlink“属性的用法与"href”属性的用法相同。您还可以使用div包围ul,并使用"cursor:hand;cursor:pointer;“设置样式,这样用户就可以意识到该图像是一个链接。
希望这能有所帮助!
发布于 2013-05-15 17:06:11
试试这个:
$('img').click(function(){
window.location.href = "http://stackoverflow.com";
});https://stackoverflow.com/questions/16560743
复制相似问题