JQuery - Pass value of variable to index value of class
<p>I'm new to js and have only been learning for about a week so be kind. The script below alters the src of an iframe to match the custom data-attribute of the same iframe when a link with a class of .thumb is clicked. </p>

<p>This works fine but its currently changing the iframe src of all classes of all iframes with a parent div class of .gallery. I just want to change the iframe src of the .gallery with the same index value as the variable 'clicked'.</p>

<pre><code>//When an link with a class of .thumb is clicked

$(document).on('click', '.thumb', function () {

    //variable index is the index of the links parent 'li'
    var clicked = $(this).parent('li').index();

    // Find iFrames of all .comm-gallery elements and alter their src to iframes data-src    value
    $('.gallery').find("iframe").prop("src", function(){

        // Set their src attribute to the value of data-src
        return $(this).data("src");
    });
});
</code></pre>

<p>I've tried numerous loop solutions over the past few hours but none have worked and, as I know little about js at this point, I imagine that I am the lowest common denominator in this. Any help would be greatly appreciated!</p>
