Home  >  Article  >  Web Front-end  >  Javascript gets the content in LI_javascript skills

Javascript gets the content in LI_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:57:421190browse

Copy code The code is as follows:

Data source:

  • Script Home


    • a_1

    • a_2< /li>
    • a_3


  • www.jb51.net

  • www.kanshule. com



<script> <br>document.write("<strong>Get the li information of the outer ul:</strong>< br>"); <br>var tree1 = document.getElementsByTagName("ul")[0].childNodes; <br>for (var i = 0;i < tree1.length;i ){ <BR>document. write(tree1[i].innerHTML); <BR>} <br><br>document.write("<br><br><strong>Get the li information of the inner layer ul:</strong> <br>"); <br><br>var tree2 = document.getElementsByTagName("ul")[1].childNodes; <br>for (var i = 0;i < tree2.length;i ){ <BR>document.write(tree2[i].innerHTML); <BR>} <br><br></script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn