[].slice.call(document.querySelectorAll('.postContainer')).forEach(function(el) { if (!el.querySelector('.file')) el.parentNode.removeChild(el); });