knot22 knot22 - 1 year ago 127
jQuery Question

translation of vanilla JavaScript to jQuery

Below is a JS function:

I'd like to update this so it uses jQuery but I am having difficulty figuring out how to translate it.

function pathContents(fileList) {
var list = document.createElement('ul');
for (file in fileList) {
var item = document.createElement('li');
return list;

Answer Source

The jQuery equivalent "all-the-way" would be:

function pathContents(fileList) {
    var $list = $('<ul/>');
    $.each(fileList, function () {
    return $list;

But the pure JavaScript way really is not that bad. For one, you cannot beat the performance of it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download