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

Javascript gets the content in LI_javascript skills

WBOY
Release: 2016-05-16 18:57:42
Original
1219 people have browsed it

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>
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template