***Dynamic List and Assignment Plz Help :)

This is my code on Atom. For some reason I can not get the list to appear on the website.

Any thoughts ?

<head>
  <title>A Great Webite</title>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>


</head>

<body>

<h1> My favourite fruits </h1>
<ol id="fruitList">
</ol>

<script>

  var fruits = ["Apple", "Orange", "Banana"];

  var list = $("#fruitList");

  $.each(fruits,function(index,value){

    $("</li>").text(value).appendTo(list);

  });

  console.log(fruits);
</script>

</body>
1 Like

Hey @Crypto_Sherlock, hope you are ok.

Did you forgot to enclose your code also with the <html > tags?

Let us know if that solve your problem :nerd_face:

Carlos Z

The html tags are there.

you should create a <li /> tag, typo error :nerd_face:

Carlos Z

Amazing. Thank you Carlos.

1 Like
<h1>My favorite fruits</h1>
<ol id='fruitList'>

</ol>

<script>
  var fruits= ["apple","orange","banana"];

  var list= $("#fruitList");

  $.each(fruits,function(index,value){
    
  var listItem =$("<li/>").text(value).appendTo(list);

  });

  console.log(fruits);



</script>

im stuck with a similar problem.I wanted to append my fruits to the list before solving the task but my list only shows the order of the list :frowning:

Solved it :partying_face: but if you came to help thank you very much :grin:

1 Like