<li> quantity in Demand:<ul> is 0, do not show <ul> and <b>;<div> <ul> quantity is 0, do not show <div>
1.html Code
//<Divclass= "MyPerson"ID= "mypersonBtn">People Management</Div><Divclass= "mypersonClass"ID= "mypersonId"> <b>Spring and autumn Five tyrants</b> <ul> </ul> <b>Three kingdoms</b> <ul> <Li><ahref="">Cao cao</a></Li> <Li><ahref="">Liu bei</a></Li> <Li><ahref="">Sun quan</a></Li> <Li><ahref="">Zhuge liang</a></Li> <Li><ahref="">Sima Yi</a></Li> <Li><ahref="">Zhou yu</a></Li> <Li><ahref="">Lu xun</a></Li> <Li><ahref="">Guo Jia</a></Li> <Li><ahref="">Xunyu</a></Li> <Li><ahref="">Guan yu</a></Li> </ul> <b>Seven Warring states</b> <ul> </ul></Div>
2.js Implementation code (don't forget to introduce jquery)
Isshowmenu ("#Mypersonid"); functionIsshowmenu (ID) {$ (id). FIND (' UL '). each (function(ulobj) {varLicount = $ ( This). Find (' Li '). length; if(licount <= 0){ $( This). Prev (). CSS (' Display ', ' none '); $( This). Remove (); } }); // varUlcount = $ (ID). FIND (' UL '). length; if(Ulcount <= 0) {$ (id). remove (); } }
JS Displays the parent directory based on the number of sub-directories