just see the code below
i just saw an video on youtube about this by its not working in my case
<head>
<script>
var r = document.getElementById("para").document.getElementsByTagName("span");
console.log(r);
</script>
</head>
<body>
<p id="nn">
<span>demand</span>
<span> demand 2</span>
<b> block of bold</b>
</p>
</body>
it should return the array containing all span tags in id="para".