The main code to use getElementsByTagName to obtain elements in a specified div is: getElementById(div_id).getElementsByTagName(tag_name);
The example is as follows:
1. HTML structure
id=test:?GlenTaneJohn Ralph
id=test0:?Glen1 span>Tane1John1Ralph1
2. JavaScript code function?fun(){
obj?=?document.getElementById("test").getElementsByTagName("span");
str=?[];
for(i=0;i str.push(obj[i].innerHTML); } alert(str); } 3. Effect demonstration