I have been trying different possibilities but I am unsure how I can achieve a proper <ul><li> structure for my scenario when using jQuery.
I am looping through the filesList array using forEach and appending <ul> which gives me the following result:
var filesList = ['Root/', 'Root/folder 1/', 'Root/folder 1/Subfolder 1/', 'Root/folder 1/Subfolder 1/textfile.txt', 'Root/folder 2/'];
var $a = $("#a");
$a.html("");
var $files = $("<ul>");
$a.append($files);
filesList.forEach(function(e) {
$files.append($("<li>", {
text: e
}));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="a"></div>
I want to achieve a full folder type structure while looping through my filesList, as shown in the following screenshot:
Is it possible to achieve this using jQuery?


jszipplugin (stuk.github.io/jszip) to read a zip file