javascript - Jquery loop coding -
i have problem jquery loop. not stopped after reach 10th element, display 10 times every element. don't know problem. must add counter (z) after if clause, because want display 10 elements of filtered items (i if must not filter elements).
the part of code:
function(data) { $.each(data.query.results.tbody, function (i, e) { .. ... .... ...... if (x != '-') { var z; (z = 0; z < 10;) { $(".news").append('xxxxx'); z++ } } }); } );
var temp=''; (z = 0; z < 10; z++) { temp += "xxxx"; } $(".news").append(temp);
append var outside loop. creare var temp, append data , after loop completes, post append: https://learn.jquery.com/performance/append-outside-loop/
Comments
Post a Comment