<ul id="yw2" class="filetree treeview">
<li id="1" class="open collapsable lastCollapsable">
<div class="hitarea open-hitarea collapsable-hitarea lastCollapsable-hitarea"></div>
<ul>
<li id="2" class="open collapsable">
<li id="6" class="open expandable">
<div class="hitarea open-hitarea expandable-hitarea"></div>
<a class="" href="/proizvodstvo/site/page?view=frameset&frame=6">ЛАЦ</a>
<ul style="display: none;">
</li>
<li id="45" class="open collapsable">
<li id="13" class="open collapsable lastCollapsable">
</ul>
</li>
<script>
console.log(document.getElementById('yw2'));
var div = document.getElementById('yw2')
var elems = div.getElementsByTagName('*')
for(var i=0; i<elems.length; i++) {
console.log(elems[i].id, elems[i].classList)
}
</script>
1 DOMTokenList["open"]
var div = document.getElementById('yw2')
var elems = div.getElementsByTagName('*')
var div = document.getElementById('yw2')
var elems = div.getElementsByTagName('*')
var elem = [];
for(var i=0; i<elems.length; i++) {
id = elems[i].id;
if (id)
elem[id] = document.getElementById(id);
}
console.log(elem[13]);
console.log(document.getElementById('13').classList.contains('open'));
elem[13].classList.toggle('open');
console.log(document.getElementById('13').classList.contains('closed'));
<li id="13" class="closed">
false
true