Home > Web Front-end > JS Tutorial > js two ways to get all li under the element_javascript skills

js two ways to get all li under the element_javascript skills

WBOY
Release: 2016-05-16 16:52:24
Original
1589 people have browsed it

js gets all li under the element

Copy code The code is as follows:

var content=document. getElementById("content");
var items=content.getElementsByTagName("ul");
var itemss=items[2].getElementsByTagName("li");

or
Copy code The code is as follows:

var div=document.getElementById('a');
var ul=div.childNodes.item(0);
var lis=ul.childNodes;
for(var i=0;ialert(" Item " i ": " lis.item(i).innerHTML);
}
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