This Django project includes a JavaScript function that generates a new div to display certain data.
for (var i = 0; i < files.length; i++) {
var newDiv = document.createElement('div');
newDiv.setAttribute("class","files_div");
//Use the helper function to determine if it's a PDF
newDiv.setAttribute("onclick","check_files(this)")
console.log(files[i]) //Print the files
newDiv.innerHTML = files[i];
divParent.appendChild(newDiv);
}
I am looking to enhance this functionality by adding icons alongside the displayed data. For instance, I want to include a PDF icon for PDF files. How can I incorporate icons in JavaScript once a new div is created?