function getTocData(){ var root = $('#toc>ul'); var data = {}; var temp = data; function getData(dom){ var data = []; dom.find('>li').each((key, item) => { }); } } $(function(){ //对于目录树的操作 if($('#toc').length > 0){ $('#toc .toctitle').append('<span class="tocmode"> [<a role="button" tabindex="1" class="modetogglelink" style="color: #aaa">切换</a>] </span>'); $('#toc ul').addClass('subtoc'); $('#toc>ul:first').removeClass('subtoc'); $('#toc .tocmode').click(function(){ alert('还没写好呢,再等等吧'); }); } });