function setPlusIcon() { var allLIs = document.getElementsByTagName("LI"); for (var i = 0; i < allLIs.length; i++) { var li = allLIs[i]; var allULs = li.getElementsByTagName("UL"); if (allULs.length > 0) { if (allULs[0].className == "expandable") li.style.listStyleImage = "url('images/plus.gif')"; } } var allA = document.getElementsByTagName('A'); for (var i = 0; i < allA.length; i++) { allA[i].addEventListener('click', aClick); } } window.onload = setPlusIcon; function aClick(e) { e = e || event; objA = e.target || e.srcElement; var li = objA.parentNode; console.log(li); var uls = li.getElementsByTagName("UL"); if (uls.length == 0) return true; if (uls[0].style.display == "") { uls[0].style.display == "block"; //**ВОТ ЗДЕСЬ НЕ УСТАНАВЛИВАЕТСЯ СВОЙСТВО block** li.style.listStyleImage = "url('images/minus.gif')"; } else { uls[0].style.display == ""; li.style.listStyleImage = "url('images/plus.gif')"; } } 
 ul.expandable li { list-style-image: url('images/point.gif') } li ul.expandable { display: none } 
 <div> <h1>Пример раскрывающегося списка</h1> <ul class="expandable"> <li> <a href="#">Книги</a> <ul class="expandable"> <li> <a href="#">Отечественные</a> <ul class="expandable"> <li><a href="#">Детективы</a> </li> <li><a href="#">Научная фантастика</a> </li> <li><a href="#">Исторические</a> </li> </ul> </li> <li> <a href="#">Зарубежные</a> <ul class="expandable"> <li><a href="#">Детективы</a> </li> <li><a href="#">Научная фантастика</a> </li> <li><a href="#">Исторические</a> </li> </ul> </li> </ul> </li> <li> <a href="#">DVD</a> <ul class="expandable"> <li> <a href="#">Отечественные</a> <ul class="expandable"> <li><a href="#">Детективы</a> </li> <li><a href="#">Научная фантастика</a> </li> <li><a href="#">Исторические</a> </li> </ul> </li> <li> <a href="#">Зарубежные</a> <ul class="expandable"> <li><a href="#">Детективы</a> </li> <li><a href="#">Научная фантастика</a> </li> <li><a href="#">Исторические</a> </li> </ul> </li> </ul> </li> </ul> </div> 

Closed due to the fact that off-topic participants Grundy , aleksandr barakin , user194374, Alex , Denis Bubnov 12 Dec '16 at 14:43 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Grundy, aleksandr barakin, Spirit of the community, Alex, Denis Bubnov
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    uls [0] .style.display == "block"; here is a comparison instead of assignment, you need uls [0] .style.display = "block"; - Dmitry Kulevich
  • @ DmitryKulevich Thank you! I will go to rest - I re-worked and could not see the elementary thing. 5 times checked the code. Thanks again! - Proshka

0