АлександраМТ,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<script>
var data = [1,2,[3,4,[5,6,7],8],9,10];
function recursiveList(data) {
var newlist = document.createElement("ul"),
item;
for (var i = 0; i < data.length; i++) {
if (typeof data[i] == "object") item = recursiveList(data[i]);
else {
item = document.createElement("li");
item.appendChild(document.createTextNode(data[i]))
}
newlist.appendChild(item)
}
return newlist
};
document.body.appendChild(recursiveList(data))
</script>
</body>
</html>
|