let foo = document.getElementById('foo'); if (foo.hasChildNodes()) { // Do something with 'foo.childNodes' }