简体   繁体   中英

can not render values of array (jquery)

hey i can not render all my values. i got names (button) if i click these i will render the array behind it. if i use.append() it will render all of them but when i click again it wil not refresh it and get stacked. what i want use is something like.text() or.html(). but i can not find the issue it wil return always the first one in the array and the other values are not showing.

 var treinen =$("#treinenArray0");
    var list = data.info[0].kwalificaties;
    $.each(list, function(index, value){
       treinen.html($('<li>'+ value + '</li>'));
    });

You seem to be not appending them but instead overwriting them.

treinen.html(treinen.html() + '<li>'+ value + '</li>'));

should append each one to the pre-existing html.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM