How can I dynamically create an unordered list in JavaScript?

前端 未结 4 2047
梦谈多话
梦谈多话 2021-01-12 00:28

I have a global JavaScript array that contains some strings.

I want to create a dynamic list based on the strings in my JavaScript array. Similar to this:

         


        
4条回答
  •  不思量自难忘°
    2021-01-12 00:37

    var $bread = $('ul.xbreadcrumbs');
    $.each(yourArray, function(index, value) {
      $('
  • ' + value + '
  • ') .appendTo($bread); });

    I have not tested this - just off my head. Hope this helps!

提交回复
热议问题