Ok, so I am building a website, and am trying to use jquery to get video thumbnails from YouTube and pass them into the corresponding images. I am still fairly new at jQuery and could use some help with the code.
Here it is:
$(function() {
$(document).ready(function() {
var length = 3; //This is the number of images I have to add a src to
for (i=0; i<length; i++) {
var vidSrc = $("img#videos").attr("vid");
$("img#videos").attr("src","http://img.youtube.com/vi/"+ vidSrc +"/2.jpg");
}
});
});
The HTML:
<img src="assets/images/LoadingAnimation.gif" id="videos" vid="peqf-LLPgZU" caption="" />
<img src="assets/images/LoadingAnimation.gif" id="videos" vid="T9vLoJa8vxY" caption="" />
<img src="assets/images/LoadingAnimation.gif" id="videos" vid="J3xr3i_wcwE" caption="" />
what I would like to do is take the vid attribute for each image and put it into the vidSrc variable...
the url of the page that I am working on is http://www.sarah.wattzup.com/#videos
Thanks in advance!