I recently encountered an issue with my JavaScript function that returns a list of elements with the class ".youtube", loops through them, and calls another function. The JavaScript logic is flawless, but I wanted to convert it into jQuery for better readability. Below is the original JS function:
var videos = document.querySelectorAll(".youtube");
for (var i = 0; i < videos.length; i++) {
getVideos(videos[i]);
}
Here is my attempt at translating it into jQuery:
$(".youtube").each(function(i, youtube){
getVideos(youtube[i]);
});
Unfortunately, this implementation did not work as expected. You can view the problem in action on JSFiddle: http://jsfiddle.net/k3y3yvxq/2/