Hi, I am pretty new to this so please excuse problems that might seem obvious...they're not necessarily obvious to me yet. I am writing some basic image gallery functionality, using my own defined jquery functions. I am trying to use .each() to loop through the "image" tags of an xml file, and create a thumbnail for each of them. I want to catch the index of each iteration to create a variable I can use to match my thumbs with my full-size images...
$.fn.createGallery = function(){ //START GALLERY OUTPUT STRING galleryOutputHTML = ""; galleryOutputHTML += "<div class='thumbs'>"; //CREATE EACH THUMBNAIL $(this).find("thumbpath").each(i).createThumb(); <<<-------------- I think I am using "i" incorrectly //CLOSE GALLERY OUTPUT STRING AND POPULATE GALLERY galleryOutputHTML += "</div>"; $("#gallery_area").append(galleryOutputHTML); }; .......then here is the .createThumb() function called above...... $.fn.createThumb = function(){ current_imageXML = $(current_galleryXML).find("image[id="i+1"]"); var thumbPath = $(this).text(); var thumbAlt = $(current_imageXML).find("image_title").text(); thumbOutputHTML = ""; thumbOutputHTML += "<img class='gallery_thumb' id="i+1" src="+thumbPath+" alt="+thumbAlt+"/>"; //ADD THUMB OUTPUT TO GALLERY OUTPUT galleryOutputHTML += thumbOutputHTML; }; What I am attempting to do is catch the index of the each loop (i) and reference it as an element id in the html output, so that the thumbnails are given the ids 1, 2, 3, etc. I am not sure I am using the i variable correctly with the .each() loop, and I can't find much documentation on how to use it when calling custom functions. Any suggestions would be appreciated. Thanks Andrew