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
WBOYOriginal
2016-05-16 16:52:241632browse

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);
}
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