This commit is contained in:
Ilya Kantor 2017-03-05 19:49:29 +03:00
parent 7b3f4550fd
commit d85be5f17b
12 changed files with 47 additions and 93 deletions

View file

@ -43,12 +43,12 @@
let lis = document.getElementsByTagName('li');
for (let li of lis) {
// получить количество детей
let childCount = li.getElementsByTagName('li').length;
if (!childCount) continue;
// get the count of all <li> below this <li>
let descendantsCount = li.getElementsByTagName('li').length;
if (!descendantsCount) continue;
// добавить кол-во детей к текстовому узлу
li.firstChild.data += ' [' + childCount + ']';
// add directly to the text node (append to the text)
li.firstChild.data += ' [' + descendantsCount + ']';
}
</script>