window onload setPlusIcon function setPlusIcon var li document getElem

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
window.onload = setPlusIcon;
function setPlusIcon(){
var li = document.getElementsByTagName('li');
for(var i = 0; i < li.length; i++){
var item = li[i];
item.addEventListener('click', aClick);
var list = item.getElementsByTagName('ul');
if(list && list.length == 0){
item.style.listStyleImage = 'none';
}
}
}
function aClick(e){
var a = e.target;
var parent = a.parentNode;
var childUl = a.nextElementSibling;
if(a.nextElementSibling){
e.preventDefault();
a.nextElementSibling.style.display = 'block';
}
}