[英]Searching for links HREF values with jQuery
I need to add a way for users to cycle through a gallery with arrows. 我需要为用户添加一种方式来循环浏览带箭头的图库。 I already have the script set up to use thumbnails with links to display larger images in a photo area. 我已经将脚本设置为使用带有链接的缩略图,以在照片区域中显示更大的图像。
The method I'm using to make the arrows work is to get the src
of the current image, and search the thumbnail links for that src
, and then find either the next or previous src
based on which arrow was clicked ( .left
or .right
). 我用来使箭头工作的方法是获取当前图像的src
,并搜索该src
的缩略图链接,然后根据点击的箭头找到下一个或上一个src
( .left
或.right
)。
Here's the issue: I don't know how to do this. 这是问题:我不知道该怎么做。 I've got the script to find the current src
when a user clicks on an arrow, but I can't figure out how to search the thumbnails for the same src or find the next or previous src. 我有脚本在用户点击箭头时找到当前的src
,但我无法弄清楚如何搜索相同src的缩略图或查找下一个或上一个src。
You can use $('img[src="'+current+'"]')
to get any images that have the same source. 您可以使用$('img[src="'+current+'"]')
来获取具有相同源的任何图像。 Presumably you want to use something like $('#thumbnails img[src=...]')
or $('img.thumb[src=...]')
to limit yourself to just the thumbnails. 大概你想要使用像$('#thumbnails img[src=...]')
$('img.thumb[src=...]')
$('#thumbnails img[src=...]')
或$('img.thumb[src=...]')
来限制自己只是缩略图。
Getting the next or previous image is a simple matter of using .next()
and .prev()
. 获取下一个或上一个图像只需使用.next()
和.prev()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.