it is suggested to attach the code. I happened to be in this situation, so I tried it and it was OK
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>getElementsByTagName</title>
</head>
<body>
<div class="box">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
<div id="content">
<ul class="con">
<li>11</li>
<li>22</li>
<li id="li3">33</li>
</ul>
<div></div>
</div>
</div>
</body>
<script type="text/javascript">
var content = document.getElementById('content');
var lis = document.getElementsByTagName('li');
var box = document.getElementsByClassName('box');
console.log(content);
console.log(lis);
console.log(box);
var lis2 = box[0].getElementsByTagName('li');
console.log(".",lis2);//.HTMLCollection(8)[li, li, li, li, li, li, li, li-sharpli3, li3: li-sharpli3]
var lis3 = content.getElementsByTagName('li');
console.log("id.",lis3);//id.HTMLCollection(3)[li, li, li-sharpli3, li3: li-sharpli3]
var divs = content.getElementsByTagName('div');
console.log("id.",divs);//id.HTMLCollection[div]
var con = content.getElementsByClassName('con');
console.log("id.",con);//id.HTMLCollection[ul.con]
var con2 = box[0].getElementsByClassName('con');
console.log(".",con2);//.HTMLCollection[ul.con]
var con3 = content.getElementById('li3');
console.log("id.id",con3);//
var content2 = box[0].getElementById('content');
console.log(".id",content2);//
</script>
</html>
add: I suddenly found that "id." is sometimes used. The tag may report an error, which may be the reason for the variable name, but it can be used directly without the variable name, and can be used directly (such as document.getElementById (). DocumentsByTagName ()) or changing the variable name
).