If you are using jQuery, why don’t you use its benefits?
Adding <li> elements:
$("<li><img src="https://stackoverflow.com/questions/10750137/"+path[i]+""></li>").appendTo(root);
Removing all <li> elements:
$(root).empty();
Deleting one <li> element:
$("li:eq(3)",$(root)).remove();
And if you are using raw JavaScript, you can use:
document.getElementById("root").innerHTML = "";