<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<p class="string"><span>1</span><i>2</i><b>3</b></p>
<script>
var str = document.querySelector('.string');
for (var i = 0; i < str.children.length; i++) {
alert(str.children[i].tagName)
}
</script>
</body>
</html>