I'm making my own image gallery and have a decent version working.
我正在制作自己的图片库并且有一个不错的版本。
I'm trying to change the link for the main image when a thumbnail image is clicked but not sure how to do this or if it can be done. I can assign a link to the thumbnail but then you can't use the gallery so I need to find a way to change the link for the main image.
我正在尝试在单击缩略图时更改主图像的链接但不确定如何执行此操作或是否可以执行此操作。我可以指定缩略图的链接,但是你不能使用图库,所以我需要找到一种方法来改变主图像的链接。
currently using the following to change the image and hoping I can get help changing the link within the same function
目前使用以下内容更改图像,并希望我可以获得帮助更改同一功能内的链接
$('#thumb1').click(function() {
$('#imgDisplay').anystretch("images/url.jpg", {speed: 1000});
$fancy magik needs to happen here I'm guessing;
});
tried adding
$("a[href='google link']").attr('href', 'other link');
to my function but it broke it, still working on it
我的功能,但它打破了它,仍在努力
1 个解决方案
#1
0
Seems that you are trying to give a link to main image.
似乎您正在尝试提供主图像的链接。
But to clarify you, you will not only need to give a link to an element to redirect to a page. you can also do some js tricks to do that using window.location.href
like...
但为了澄清您,您不仅需要提供指向元素的链接以重定向到页面。你也可以使用window.location.href做一些js技巧来做...
$('#imgDisplay').click(function() {
window.location.href = 'your path here';
});
And OWWWWWW... to make your code more readable and clean.. for element with the same functionality, use class instead of an id for your event listeners.
并且为了使代码更具可读性和清洁性...对于具有相同功能的元素,请为事件监听器使用class而不是id。
#1
0
Seems that you are trying to give a link to main image.
似乎您正在尝试提供主图像的链接。
But to clarify you, you will not only need to give a link to an element to redirect to a page. you can also do some js tricks to do that using window.location.href
like...
但为了澄清您,您不仅需要提供指向元素的链接以重定向到页面。你也可以使用window.location.href做一些js技巧来做...
$('#imgDisplay').click(function() {
window.location.href = 'your path here';
});
And OWWWWWW... to make your code more readable and clean.. for element with the same functionality, use class instead of an id for your event listeners.
并且为了使代码更具可读性和清洁性...对于具有相同功能的元素,请为事件监听器使用class而不是id。