简体   繁体   English

通过Javascript从HTML文件中获取href值

[英]Fetch href Value from HTML File via Javascript

I have this Problem. 我有这个问题。

I am using Grid.js ( http://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/ ) 我正在使用Grid.js( http://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/

And now I want to add a Lightbox with multiple thumbnails inside the dropout. 现在,我想在辍学中添加一个包含多个缩略图的灯箱。

Grid.js has an function where it puts all the content into the dropout, so I thought I may use this function. Grid.js具有将所有内容放入辍学对象的功能,所以我认为我可以使用此功能。

this.$href = $('<div class="image-row"><div class="image-set"><a class="example-image-link" href="img/demopage/image-3.jpg" data-lightbox="example-set" title="Click on the right side of the image to move forward."></div>');

I shortenend the code, its very long (not very pretty I admitt), now it shows on the dropout, but I need for each Dropout a new set of images. 我缩短了代码,它的代码很长(我承认不是很漂亮),现在它显示在Dropout上,但是我需要为每个Dropout设置一组新的图像。

Is there any way I can fetch the href="" data out of the HTML? 有什么方法可以从HTML中获取href =“”数据? Or another, more practical way to do it? 还是另一种更实用的方法呢?

I admit I have absolutly no clue of JavaScript.... I hope someone can help me! 我承认我完全不了解JavaScript...。希望有人能帮助我! Thanks in Advance 提前致谢

在jQuery中,您可以使用$('.example-image-link').attr('href');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM