var elems = document.querySelectorAll('.class-title, .class-text'), massive = document.getElementById('massive'); [].forEach.call(elems, function(self) { massive.value += '<p>' + self.innerHTML + '</p>\n'; });