It is so eazy!
<html>
<head>
<title>span计数</title>
</head>
<body>
<div class="scroll">
<span>span计数1</span>
<span>span计数2</span>
<span>span计数3</span>
<span>span计数4</span>
<span>span计数5</span>
</div>
</body>
<script>
const set = new Set();
document.querySelectorAll('span').forEach(x=>{
set.add(x)
})
console.log(set.size);
</script>
</html>