var popupText = document.querySelectorAll(".text"), allPopupText = []; for (var i = 0; i < popupText.length; i++){ allPopupText[i] = popupText[i].className; } alert(allPopupText);