[Solved] Each Iteration overrides my defined variable
Howdy,
i've tried to search with google for problem but i can't find any solution. And i'm also not really familar with JavaScript :o/
My problem is jQuery overrides on each iteration the current value of my variable. So i get only the last element. Logically normal imho. But how can i solve it?
This is the specific part of my code:
- $(this).find("product").each(function() {
getProducts = '<li>' + $(this).attr('artikelnummer') + "</li>";
});
Here you can see the whole context:
- $.ajax({
type: "GET",
url: "xml/slides.xml",
dataType: "xml",
success: parseXml
});
function buildSlide(slide) {
var $output = $("#output");
var slideOpen = '<div class="slide">';
var slideClose = '</div>';
$(xml).find("slide[number=" + slide + "]").each(function() {
getImage = '<img width="500" src="' + $(this).find('visual').attr('path') + '"/>';
$(this).find("product").each(function() {
getProducts = '<li>' + $(this).attr('artikelnummer') + "</li>";
});
});
}
$output.append(slideOpen + getImage + getProducts + slideClose);
Thanks for reading.