How To Create List From JSON Array?

前端 未结 5 812
渐次进展
渐次进展 2021-01-05 20:44

I have problem understanding arrays and loops, therefore this task is a bit confusing to me. Here\'s my stuff;

JSON

{
\"states\": [
         


        
5条回答
  •  别那么骄傲
    2021-01-05 21:19

    Jquery can create elements and append to your documents with few lines of code.

    You can create an empty list like this.

     var mylist=$("
      ");

      Then inside your for loop, for each item, do something like this

      mylist.append($("
    • ").text(item.name));

      And finally append your newly built list to your document to get it displayed:

      mylist.appendTo($("body"));
      

    提交回复
    热议问题